Python爬虫识别验证码
安装tesserocr
pip3 install tesserocr pillow
识别测试
将验证码图片放到项目根目录下,用tesserocr库识别该验证码,代码如下所示:
0 1 2 3 4 5 6 7 |
import locale locale.setlocale(locale.LC_ALL, 'C') import tesserocr from PIL import Image image = Image.open('code.jpg') result = tesserocr.image_to_text(image) print(result) |