爬虫最头痛的是反爬和验证码!用这个操作!验证码形同虚设!
发布时间:2020-12-17 00:37:34 所属栏目:Python 来源:网络整理
导读:II. Tesseract编译安装 git clone https://github.com/tesseract-ocr/tesseract/cd tesseract./autogen.sh./configure CC=gcc-8 CXX=g++-8 CPPFLAGS=-I/usr/local/opt/icu4c/include LDFLAGS=-L/usr/local/opt/icu4c/libmake -jsudo make install # if desir
II. Tesseract编译安装 git clone https://github.com/tesseract-ocr/tesseract/ cd tesseract ./autogen.sh ./configure CC=gcc-8 CXX=g++-8 CPPFLAGS=-I/usr/local/opt/icu4c/include LDFLAGS=-L/usr/local/opt/icu4c/lib make -j sudo make install # if desired III. 语言配置 需要识别语言配置(参照 教程 ):
比如我这边是4.0版本,我需要的是对英文的ocr识别(识别英文的验证码),我就直接下载4.00版本的 eng.traineddata : 然后再将下载下来的 eng.traineddata 放到到 /usr/local/share/tessdata 中即可: 进群:548377875? 即可获取数十套PDF以及大量小编精心整理的基础教程哦!PDF是从零到项目实战的! IV. 打通Python 这边打通python直接通过 pytesseract ,十分方便。 先安装pillow: pip install pillow 再安装pytesseract: pip install pytesseract 安装完成后就可以通过其在python中使用了,如: try: from PIL import Image except ImportError: import Image import pytesseract # Simple image to string print(pytesseract.image_to_string(Image.open('test.png'))) # French text image to string print(pytesseract.image_to_string(Image.open('test-european.jpg'),lang='fra')) 更多使用方法参照 官方 的文档。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |