码迷,mamicode.com
首页 > 编程语言 > 详细

python识别验证码

时间:2017-11-04 11:32:43      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:from   code   xxxx   get   install   pytho   setup   request   image   

1、python识别验证码依赖 tesseract-ocr-setup-3.02.02.exe,所以首先需要安装 tesseract-ocr-setup-3.02.02.exe

2、然后安装pytesseract,通过pytesseract调用tesseract-ocr来识别验证码。pip install pytesseract

运行代码:

import requests
from PIL import Image
from StringIO import StringIO
import pytesseract

res = requests.get(‘http://xxxxx/validateCode?‘)
#print res.content
i = Image.open(StringIO(res.content))
i.save(‘code.jpg‘,‘JPEG‘)
print pytesseract.image_to_string(i)

python识别验证码

标签:from   code   xxxx   get   install   pytho   setup   request   image   

原文地址:http://www.cnblogs.com/cppsurain/p/7782215.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!