Selenium python34+selenium 识别验证码

马可菠菠仔 · 2017年07月27日 · 最后由 wangan 回复于 2017年08月01日 · 1283 次阅读

from selenium import webdriver
import os
import pytesser
import sys,time
from PIL import Image,ImageEnhance

im = Image.open("G:\1.png")
imgry = im.convert('L') # 图像加强,二值化
sharpness = ImageEnhance.Contrast(imgry) # 对比度增强
sharp_img = sharpness.enhance(2.0)
sharp_img.save("G:\1.png")
code = pytesser.image_file_to_string("G:\1.png") # code 即为识别出的图片数字 str 类型
print(code)

网上搜来的代码,想套用
结果在使用过程中报错
C:\Python34\python.exe "C:/Users/dell/PycharmProjects/practice/.idea/inspectionProfiles/verification code.py"
Traceback (most recent call last):
File "C:/Users/dell/PycharmProjects/practice/.idea/inspectionProfiles/verification code.py", line 17, in
code = pytesser.image_file_to_string("G:\1.png") # code 即为识别出的图片数字 str 类型
AttributeError: 'module' object has no attribute 'image_file_to_string'

Process finished with exit code 1
有没有做过类似东西的老师,求指教

共收到 3 条回复 时间 点赞

好像变成了 pytesseract,装这个试试?

试试 pytesser.image_to_string 呢?

还是不要用了,识别正确率很低,有这时间,不如去和开发聊聊

马可菠菠仔 关闭了讨论 09月13日 10:42
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册