参考:

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. 【iOS】PLA 3.3.12

    发件人 Apple Program License Agreement PLA We found that your app uses the Advertising Identifier but d ...

  2. 【Android】ViewModel+LiveData:更加直接地控制视图的方式

    目录 LiveData 前言 使用ViewModel+LiveData LiveData 前言   ViewModel通过将UI data保存在ViewModel类实例的内部,从而大大地将MVC中的 ...

  3. 什么是redis的缓存雪崩与缓存穿透

    今天来分享一下Redis几道常见的面试题: 如何解决缓存雪崩? 如何解决缓存穿透? 如何保证缓存与数据库双写时一致的问题? 一.缓存雪崩 1.1 什么是缓存雪崩? 首先我们先来回答一下我们为什么要用缓 ...

  4. H3C模拟器单臂路由配置实例

    单臂路由:用802.1Q和子接口实现VLAN间路由 单臂路由利用trunk链路允许多个VLAN的数据帧通过而实现 网络拓扑图: RTA配置: SW1配置: PC1/2配置如图: 但是值得注意的是,在配 ...

  5. Linq查找最大值max最小值min效率比较

    对linq查找极值的几种方法做一个效率上的比较 // 首先创建了一个10_000_000大小的PointF列表 var rdn = new Random(); var points = Enumera ...

  6. 七牛云qshell工具定时备份空间文件到本地

    qshell 是利用七牛文档上公开的 API实现的一个方便开发者测试和使用七牛API服务的命令行工具,使用该工具可以实现很多的功能,今天就分享一下利用qshell定时备份空间文件到本地 1.下载qsh ...

  7. 【Java例题】2.2 分数类

    2.定义分数类,包括分子和分母变量.构造方法. 加减乘除方法.化简方法.值计算方法和显示分子和分母的方法. 然后编写一个主类,在其主方法中通过定义两个分数对象来 显示每一个分数的分子值.分母值.化简和 ...

  8. unity 四叉树管理场景

    当场景元素过多时,需要实时的显示及隐藏物体使得性能提示,但是物体那么多,怎么知道哪些物体需要显示,哪些物体不需要显示的.当然,遍历物体判断该物体是否可以显示是最容易想到的方法,但是每次更新要遍历所有物 ...

  9. MySQL学习随笔记录

    安装选custmer自定义安装.默认安装全部在c盘.自定义安装的时候有个advance port选项用来选择安装目录. -----------------------MySQL常见的一些操作命令--- ...

  10. 【原创】微信小程序支付java后台案例(公众号支付同适用)(签名错误问题)

    前言 1.微信小程序支付官方接口文档:[点击查看微信开放平台api开发文档]2.遇到的坑:预支付统一下单签名结果返回[签名错误]失败,建议用官方[签名验证工具]检查签名是否存在问题.3.遇到的坑:签名 ...