如何使用Python / Selenium获取验证码文本?我已经尝试过使用此处提供的多个脚本。
代码:
import pytesseract
import sys
import argparse
try:
import Image
except ImportError:
from PIL import Image
from subprocess import check_output
path="C:\\...\\Desktop\\Captcha_test_demo.jpg"
sys.path.append(path)
def resolve(path):
print("Resampling the Image")
check_output(['convert', path, '-resample', '600', path])
return pytesseract.image_to_string(Image.open(path))
argparser = argparse.ArgumentParser()
argparser.add_argument(path,help = 'Captcha file path')
args = argparser.parse_args()
path = args.path
print('Resolving Captcha')
captcha_text = resolve(path)
print('Extracted Text', captcha_text)
错误:
#Error: usage: captcha_resolver.py [-h] C:\...\Desktop\Captcha_test_demo.jpg #captcha_resolver.py: error: the following arguments are required: #C:\.....\Desktop\Captcha_test_demo.jpg