python 登录自动识别验证码
环境
- Python 3.6.3
- pip 9.0.1
- tesseract-ocr-setup-3.05.00dev.exe
- Pillow
- selenium
- Windows10
ptesseract安装
1.tesseract-orc
安装的时候需要自行选择安装的语言,一些其他国家的语言可以不选择安装,我之按安装了中文,英文和日语。安装过程和其他软件一样。
2.pytesseract
配置环境
1.设置 tesseract-orc路径
默认情况下tesseract-orc是不被添加到系统的path路径的,这样在使用的时候发生FileNotFoundError: [WinError 2] 系统找不到指定的文件
错误。
解决方法:
* 方法1:将 C:\Program Files (x86)\Tesseract-OCR
添加到系统路径(路径因安装过程而异)
* 方法2:修改pytesseract.py文件,修改方法如下
- 设置训练集的位置
下载的默认训练集也没有添加到系统路径,会报错pytesseract.pytesseract.TesseractError: (1, 'Error opening data file \\Program Files (x86)\\Tesseract-OCR\\tessdata/chi_sim.traineddata')
解决方法:
设置环境变量 TESSDATA_PREFIX
C:\Program Files (x86)\Tesseract-OCR\tessdata
Pillow安装
1.Pillow
selenium安装
1.selenium