python 登录自动识别验证码

环境

  • Windows10

ptesseract安装

1.tesseract-orc

安装的时候需要自行选择安装的语言,一些其他国家的语言可以不选择安装,我之按安装了中文,英文和日语。安装过程和其他软件一样。

2.pytesseract

python 登录自动识别验证码


配置环境

1.设置 tesseract-orc路径

默认情况下tesseract-orc是不被添加到系统的path路径的,这样在使用的时候发生FileNotFoundError: [WinError 2] 系统找不到指定的文件错误。

解决方法: 
* 方法1:将 C:\Program Files (x86)\Tesseract-OCR添加到系统路径(路径因安装过程而异) 
* 方法2:修改pytesseract.py文件,修改方法如下 

  1. 设置训练集的位置

下载的默认训练集也没有添加到系统路径,会报错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

python 登录自动识别验证码

selenium安装

1.selenium

python 登录自动识别验证码


实例程序

python 登录自动识别验证码