参考:

http://oatest.dragonbravo.com/Authenticate/SignIn?returnUrl=%2f

http://drops.wooyun.org/tips/6313

http://blog.csdn.net/nwpulei/article/details/8457738

http://www.pythonclub.org/project/captcha/python-pil

http://blog.csdn.net/csapr1987/article/details/7728315  创建二维码图片

python验证码识别库安装

1.安装图像处理库PIL,即Python Image Library。

下载地址:http://www.pythonware.com/products/pil/

2. 安装google OCR识别引擎pytesseract

以管理员身份运行命令提示行。

cd C:\Python27\Scripts

pip install pytesseract

单色无干扰验证码识别

对于完全单色没有任何干挠的验证码,识别起来比较容易。代码如下:

import os
import pytesseract
import Image os.chdir('C:\Users\Administrator\Downloads\picture')
image = Image.open('verifycode.jpg')
vcode = pytesseract.image_to_string(image)
print vcode

彩色有干扰验证码识别

  1. 中值过滤去噪。此种类型验证码包含了噪点,所以第一步就是去噪。
  2. 对图像亮度进行加强处理。中值过滤时,不少噪点淡化了,但是如果直接转换为单色,这些噪点又被强化显示了,因此增加这一步对图像亮度进行加强处理。
  3. 转换为单色。即通过二值化,将低于阈值的设置为0,高于阈值的设置为1,从而实现将图片变为黑白色。黑色像素输出1,白色像素输出0。

代码如下:

os.chdir('C:\Users\Administrator\Downloads\picture')
image = Image.open('vcode.gif')
images = image.filter(ImageFilter.MedianFilter())
enhancer = ImageEnhance.Contrast(images)
images = enhancer.enhance(2)
images = images.convert('')
images.show()

验证码图像处理脑图如下:

附上pytesseract简介:

Metadata-Version: 1.1
Name: pytesseract
Version: 0.1.6
Summary: Python-tesseract is a python wrapper for google's Tesseract-OCR
Home-page: https://github.com/madmaze/python-tesseract
Author: Matthias Lee
Author-email: pytesseract@madmaze.net
License: GPLv3
Description: Python-tesseract is an optical character recognition (OCR) tool for python.
        That is, it will recognize and "read" the text embedded in images.
       
        Python-tesseract is a wrapper for google's Tesseract-OCR
        ( http://code.google.com/p/tesseract-ocr/ ).  It is also useful as a
        stand-alone invocation script to tesseract, as it can read all image types
        supported by the Python Imaging Library, including jpeg, png, gif, bmp, tiff,
        and others, whereas tesseract-ocr by default only supports tiff and bmp.
        Additionally, if used as a script, Python-tesseract will print the recognized
        text in stead of writing it to a file. Support for confidence estimates and
        bounding box data is planned for future releases.
       
       
        USAGE:
        ```
         > try:
         >     import Image
         > except ImportError:
         >     from PIL import Image
         > import pytesseract
         > print(pytesseract.image_to_string(Image.open('test.png')))
         > print(pytesseract.image_to_string(Image.open('test-european.jpg'), lang='fra'))
        ```
       
        INSTALLATION:
       
        Prerequisites:
        * Python-tesseract requires python 2.5 or later or python 3.
        * You will need the Python Imaging Library (PIL).  Under Debian/Ubuntu, this is
          the package "python-imaging" or "python3-imaging" for python3.
        * Install google tesseract-ocr from http://code.google.com/p/tesseract-ocr/ .
          You must be able to invoke the tesseract command as "tesseract". If this
          isn't the case, for example because tesseract isn't in your PATH, you will
          have to change the "tesseract_cmd" variable at the top of 'tesseract.py'.
          Under Debian/Ubuntu you can use the package "tesseract-ocr".
         
        Installing via pip:  
        See the [pytesseract package page](https://pypi.python.org/pypi/pytesseract)  
        ```
        $> sudo pip install pytesseract  
        ```
       
        Installing from source:  
        ```
        $> git clone git@github.com:madmaze/pytesseract.git  
        $> sudo python setup.py install 
        ```
       
        LICENSE:
        Python-tesseract is released under the GPL v3.
       
        CONTRIBUTERS:
        - Originally written by [Samuel Hoffstaetter](https://github.com/hoffstaetter)
        - [Juarez Bochi](https://github.com/jbochi)
        - [Matthias Lee](https://github.com/madmaze)
        - [Lars Kistner](https://github.com/Sr4l)
Keywords: python-tesseract OCR Python
Platform: UNKNOWN
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 3

Windows平台python验证码识别的更多相关文章

  1. Python+Request库+第三方平台实现验证码识别示例

    1.登录时经常的出现验证码,此次结合Python+Request+第三方验证码识别平台(超级鹰识别平台) 2.首先到超级鹰平台下载对应语言的识别码封装,超级鹰平台:http://www.chaojiy ...

  2. python验证码识别

    关于利用python进行验证码识别的一些想法 用python加“验证码”为关键词在baidu里搜一下,可以找到很多关于验证码识别的文章.我大体看了一下,主要方法有几类:一类是通过对图片进行处 理,然后 ...

  3. Python 验证码识别-- tesserocr

    Python 验证码识别-- tesserocr tesserocr 是 Python 的一个 OCR 识别库 ,但其实是对 tesseract 做的一 层 Python API 封装,所以它的核心是 ...

  4. 【转】Python验证码识别处理实例

    原文出处: 林炳文(@林炳文Evankaka) 一.准备工作与代码实例 1.PIL.pytesser.tesseract (1)安装PIL:下载地址:http://www.pythonware.com ...

  5. Python 验证码识别(别干坏事哦...)

    关于python验证码识别库,网上主要介绍的为pytesser及pytesseract,其实pytesser的安装有一点点麻烦,所以这里我不考虑,直接使用后一种库. python验证码识别库安装 要安 ...

  6. Windows平台Python Pyramid实战从入门到进阶:第一个服务

    Pyramid是比较流行的Python Web 框架,比较灵活,功能也很强大.最近项目上用到,便打算学习一下.网上教程比较少,而且很多都是针对linux平台的,我是windows土著所以对那些linu ...

  7. windows平台python 2.7环境编译安装zbar

    最近一个项目需要识别二维码,找来找去找到了zbar和zxing,中间越过无数坑,总算基本上弄明白,分享出来给大家. 一.zbar官方介绍 ZBar 是款桌面电脑用条形码/二维码扫描工具,支持摄像头及图 ...

  8. Python验证码识别处理实例(转载)

    版权声明:本文为博主林炳文Evankaka原创文章,转载请注明出处http://blog.csdn.net/evankaka 一.准备工作与代码实例 1.PIL.pytesser.tesseract ...

  9. Python验证码识别处理实例(转)

    一.准备工作与代码实例 1.PIL.pytesser.tesseract (1)安装PIL:下载地址:http://www.pythonware.com/products/pil/(CSDN下载) 下 ...

随机推荐

  1. 关于STM32F103+ESP8266+阿里云过程之设备状态更新至阿里云(三)

    设备与阿里云完成发布订阅的功能,接下来就是将设备状态如温湿度,PM2.5值上报更新至阿里云. 1.查看Topic. 在阿里云平台上 设备->Topic列表中查看.在产品中也可以看到对应的Topi ...

  2. vue history模式下出现空白页情况

    问题描述:   vue搭建的项目,路由一直用的hash模式,所以url中都会带有一个“#”号.现在想要去掉“#”,于是使用history模式 { mode: 'history' },代码如下: imp ...

  3. c&c服务器(command and control server)

    远程命令和控制服务器,目标机器可以接收来自服务器的命令,从而达到服务器控制目标机器的目的.该方法常用于病毒木马控制被感染的机器.

  4. Linux中更新firefox

    从官网下载Firefox压缩包放在/usr/lib/目录下(应用程序一般都在这个文件夹下) tar jxfv [压缩包名]  解压得到文件夹firefox在解压得到的firefox文件夹中有一个fir ...

  5. codeforces 340 A. The Wall

    水水的一道题,只需要找xy的最小公倍数,然后找a b区间有多少个可以被xy的最小公倍数整除的数,就是答案. //============================================ ...

  6. codeforces 327 B. Hungry Sequence

    题目链接 题目就是让你输出n个数的序列,要保证该序列是递增的,并且第i个数的前面不能保护它的约数,我直接先对前100000的素数打表,然后输出前n个,so easy. //cf 191 B #incl ...

  7. Web容器启动中执行某个Java类

    1.监听(Listener) <!-- 配置监听 --> <listener> <listener-class>com.xian.jdbc.GetPropertie ...

  8. 01-Spring Security框架学习--入门(二)

    一.入门案例 Spring Security 自定义登录界面 通过之前的一节 01-Spring Security框架学习--入门(一)的简单演示,Spring security 使用框架自带的登录界 ...

  9. print('', end='')

    print函数的end参数,从python3才开始支持,所以如果要使用这种模式,需要对应使用python3

  10. Jersey用户指南学习笔记1

    Jersey用户指南是Jersey的官方文档, 英文原版在这:https://jersey.github.io/documentation/latest/index.html 中文翻译版在这:http ...