验证码问题
1、验证码:放置机器人或者爬虫
2、分类
-简单图片
-极验,官网:www.geeetest.com
-12306
-电话
-google验证
3、验证码破解
-运用方法:
-下载网页和验证码
-手动输入验证号码
-简单图片
-使用图像识别软件或者文字识别软件
-可以使用第三方图像验证码破解网站,www.chaojiying.com
-极验,官网:www.geetest.com
-破解比较麻烦
-可以模拟鼠标等移动
-一直在进化
-12306
-电话:语音识别
-google验证
Tesseract
-机器视觉领域的基础软件
-OCR:OpticalChracterRecognition,光学文字识别
-Tesseract:一个ocr库,有google赞助
-安装:
-windows下:官方下载:https://github.com/UB-Mannheim/tesseract/wiki
安装及环境配置说明:https://jingyan.baidu.com/article/219f4bf788addfde442d38fe.html
-Mac:brew install tesseract
-Linux:apt-get install tesseract-ocr
-安装完后还需要pytesseract
-pip install pytesseract
import pytesseract as pt
from PIL import Image
#生成图片实例
image = Image.open('/home/dz/桌面/3.jpg')
#调用pytesseract,把图片转换成文字
#返回结果就是转换成的结果
text = pt.image_to_string(image)
print(text)
错误:pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path
解决:
pytesseract安装后,在python(我的是anaconda)的Lib目录下site-packges下会生成一个pytesseract文件夹,在文件夹中找到pytesseract.py,使用记事本打开pytesseract.py,找到如下两行:
# CHANGE THIS IF TESSERACT IS NOT IN YOUR PATH, OR IS NAMED DIFFERENTLY
tesseract_cmd = 'tesseract'
将tesseract_cmd = 'tesseract'修改为:tesseract_cmd = 'D:/tesseract/tesseract.exe'
表示tesseract_cmd配置的是你安装tesseract的绝对路径,这样就能找到tesseract了。修改后保存,再去运行python代码,就可以成功了。