首页 > 代码库 > [原]Python 使用pytesseract库识别验证码(MAC系统)
[原]Python 使用pytesseract库识别验证码(MAC系统)
1.安装python
brew install python
2.安装PIL及图片格式支持
下载
http://www.pythonware.com/products/pil/index.htm
解压
tar -xzf Imaging-1.1.7.tar.gz
安装PIL
cd Imaging-1.1.7
sudo python setup.py install
安装图片格式支持
brew install libpng
brew install jpeg
brew install libtiff
(注:安装了libtiff后PIL仍然无法支持tiff格式的图片,原因还没搞清楚)
3.安装leptonica
brew install leptonica
4.安装tesseract-ocr
brew install tesseract
5.安装pytesseract库
安装pip工具
sudo easy_install pip
安装pytesseract
sudo pip install pytesseract
6.写python脚本并运行
import pytesseractfrom PIL import Imageimage = Image.open(‘yzm.png‘)image.load()image.split()vcode = pytesseract.image_to_string(image)print vcode
其中yzm.png为验证码图片,和py脚本同一个目录
py脚本保存为yzm.py,运行之
python yzm.py
显示结果
[原]Python 使用pytesseract库识别验证码(MAC系统)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。