爬虫最头痛的是反爬和验证码!用这个 *** 作!验证码形同虚设!

爬虫最头痛的是反爬和验证码!用这个 *** 作!验证码形同虚设!,第1张

概述 II.Tesseract编译安装gitclonehttps://github.com/tesseract-ocr/tesseract/cdtesseract./autogen.sh./configureCC=gcc-8CXX=g++-8CPPFLAGS=-I/usr/local/opt/icu4c/includeLDFLAGS=-L/usr/local/opt/icu4c

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 desired

III. 语言配置

需要识别语言配置(参照 教程 ):

前面安装完后,你会发现在 /usr/local/share/tessdata 会有默认的data,将 export TESSDATA_PREFIX='/usr/local/share/tessdata' 配置到系统环境中 在 这里 下载对应版本的语言包 将下载的语言包直接放到这个 /usr/local/share/tessdata

比如我这边是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 Imageexcept importError: import Imageimport PyTesseract# Simple image to stringprint(PyTesseract.image_to_string(Image.open('test.png')))# french text image to stringprint(PyTesseract.image_to_string(Image.open('test-european.jpg'),lang='fra'))

更多使用方法参照 官方 的文档。

总结

以上是内存溢出为你收集整理的爬虫最头痛的是反爬和验证码!用这个 *** 作!验证码形同虚设!全部内容,希望文章能够帮你解决爬虫最头痛的是反爬和验证码!用这个 *** 作!验证码形同虚设!所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1208562.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-04
下一篇 2022-06-04

发表评论

登录后才能评论

评论列表(0条)

保存