利用python pytesser 识别简单验证码
来源:互联网 发布:tc c语言现在版本 编辑:程序博客网 时间:2024/05/16 08:11
最近在学python , 开始写点简单的爬虫小程序。真真感觉到python写爬虫软件很是简单。
但在写的过程中,也遇到了好多问题,有需要设置User-Agent的,有需要处理重定向,有需要设置cookies的等等。
不过还是听起来很动人。于是开始动手捣鼓。查了下相关资料,发现这东西还挺复杂,有好多依赖。
PyTesser uses the Tesseract OCR engine, converting images to an accepted format and calling the Tesseract executable as an external script. A Windows executable is provided along with the Python scripts. The scripts should work in other operating systems as well.
Dependencies
PIL is required to work with images in memory. PyTesser has been tested with Python 2.4 in Windows XP.
说是Pytesser使用了Tesseract OCR的识别引擎,而PIL则是用来处理装载到内存中的图片的。
那就是需要以下软件了呗:
pytesser
http://code.google.com/p/pytesser/
Tesseract OCR engine
http://code.google.com/p/tesseract-ocr/
PIL
http://www.pythonware.com/products/pil/
楼主使用的WIN7 64bit, 用的python2.7 32bit的
安装的是 tesseract-ocr-setup-3.02.02 , PIL-1.1.7.win32-py2.7 ,pytesser_v0.0.1
但在写的过程中,也遇到了好多问题,有需要设置User-Agent的,有需要处理重定向,有需要设置cookies的等等。
在爬取一些需要验证的之类网站的数据时,验证码图片识别几乎是无法避免需要解决的问题。
楼主虽然是计算机专业的,但是对于图片识别算法之类的从来没有接触过。虽然可以搜索到许多的现成代码,但大部分都是需要定制的,例如有专门处理删除线图片的代码,专门去除噪点的代码等等。更是对一些高大上的算法,比如截图,二值化、中值滤波去噪、分割、紧缩重排(让高矮统一)、字库特征匹配识别等等两眼一抹黑。
在网上闲逛,发现了后来找到一个python OCR软件pytesser。只需要简单的一句代码就可以实现上面这种验证码的识别。但是这个插件并不支持所有的验证码识别,如果图片高低不等的话是无法实别出来的。太复杂的验证码也没办法实别。毕竟对于那种高端验证码,也不能指望一个类库就能解决问题 -_-不过还是听起来很动人。于是开始动手捣鼓。查了下相关资料,发现这东西还挺复杂,有好多依赖。
PyTesser uses the Tesseract OCR engine, converting images to an accepted format and calling the Tesseract executable as an external script. A Windows executable is provided along with the Python scripts. The scripts should work in other operating systems as well.
Dependencies
PIL is required to work with images in memory. PyTesser has been tested with Python 2.4 in Windows XP.
说是Pytesser使用了Tesseract OCR的识别引擎,而PIL则是用来处理装载到内存中的图片的。
那就是需要以下软件了呗:
pytesser
http://code.google.com/p/pytesser/
Tesseract OCR engine
http://code.google.com/p/tesseract-ocr/
PIL
http://www.pythonware.com/products/pil/
楼主使用的WIN7 64bit, 用的python2.7 32bit的
安装的是 tesseract-ocr-setup-3.02.02 , PIL-1.1.7.win32-py2.7 ,pytesser_v0.0.1
PIL和Tesseract是exe的文件,直接安装就可以了,而pytesser更是简单,直接解压到C:\Python27\Lib\site-packages中即可。
环境弄好以后,直接写两段代码试验一下吧!
from pytesser import *im = Image.open('code.jpg')textcode = image_to_string(im)print textcode
对不同类型的验证码应该还可以调节一些参数什么的提高准确率的,这些就留给以后再说吧!
0 0
- 利用python pytesser 识别简单验证码
- Python验证码识别:利用pytesser识别简单图形验证码
- Python验证码识别:利用pytesser识别简单图形验证码
- python中的验证码识别库PyTesser
- python中的验证码识别库PyTesser
- Python识别验证码的模块--- pytesser
- python pytesser 识别图片验证码
- python pytesser tesseract-ocr 验证码识别
- Python2.7+pytesser简单验证码的识别
- Python2.7+pytesser简单验证码的识别
- win7 selenium python 验证码识别 pytesser使用 安装Pillow、pytesser、tesseract-ocr
- Python2.7 Pytesser识别验证码
- python 验证码识别:pytesser .image_file_to_string('1.tif') WindowsError: [Error 2] 解决办法
- Win7下安装Python图像处理库PIL、pytesser、tesseract进行验证码识别
- 利用Python进行简单的图像识别(验证码)
- 利用Python进行简单的验证码识别步骤
- pytesser简单的图形识别
- python简单验证码识别
- hdu1874 畅通工程续(单元最短路)
- C/C++中static关键字详解
- 字节间反转和字节内反转
- ubuntu下关闭apache和mysql的开机启动
- 目标
- 利用python pytesser 识别简单验证码
- 电脑死机解决方法:十四招
- 使用freopen重定向输入输出流
- cs硕士妹子找工作经历【阿里人搜等互联网】
- PDF产品套装
- chm格式电子书另类反编译法:使用压缩软件7Z简单实现CHM电子书反编译 | 志文工作室
- Mac下MySQL卸载方法
- 精湛的WinXP优化技术:10招
- css 中浮动(Float)的作用