参考:

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. 02 | 健康之路 kubernetes(k8s) 实践之路 : 生产可用环境及验证

    上一篇< 01 | 健康之路 kubernetes(k8s) 实践之路 : 开篇及概况 >我们介绍了我们的大体情况,也算迈出了第一步.今天我们主要介绍下我们生产可用的集群架设方案.涉及了整 ...

  2. .net持续集成sonarqube篇之 sonarqube与jenkins集成(插件模式)

    系列目录 Jenkins通过插件集成Sonarqube 通过上一节我们了解了如何配置以使jenkins ci环境中可以执行sonarqube构建,其实Sonarqube官方也提供了jenkins插件以 ...

  3. 【CocoaPods】ERROR: While executing gem ... Gem::DependencyError

    今天安装 CocoaPods 时遇到了这个问题. ERROR: While executing gem ... (Gem::DependencyError) Unable to resolve dep ...

  4. 用python twilio模块实现发手机短信的功能

    前排提示:这个模块不是用于对陌生人进行短信轰炸和电话骚扰的,这个模块也没有这个功能,如果是抱着这个心态来的,可以关闭网页了 语言:python 步骤一:安装twilio模块 pip install t ...

  5. 【Python-Django模型迁移】用户数据库模型的迁移(对其他数据库迁移同样适用)!!!

    迁移用户模型类 1. 指定用户模型类 文档 思考:为什么Django默认用户模型类是User? 阅读源代码:'django.conf.global_settings’ AUTH_USER_MODEL ...

  6. 开发一个Spring Boot Starter!

    在上一篇文章中,我们已经了解了一个starter实现自动配置的基本流程,在这一小结我们将复现上一过程,实现一个自定义的starter. 先来分析starter的需求: 在项目中添加自定义的starte ...

  7. python基础之条件控制

    行与缩进 python使用缩进来表示代码块,不需要使用大括号 {} ,同一个代码块的语句必须包含相同的缩进空格数. 条件控制 #条件控制语法: if 条件: 代码块 elif 条件: 代码块 else ...

  8. 封装 Gson 解析Json到对象是否失败

    在使用Google的 Gson 类库解析 Json 数据时,难免会出现解析失败的情况. 在这种情况下,使用 if(obj == null) 是不可行的,fromJson 方法会自动生成对象的实例,所以 ...

  9. JavaScript的event对象

    JavaScript的event对象中 event.target指代的是:触发事件的元素 event.currentTarget指代的是:事件绑定的元素 <!DOCTYPE html> & ...

  10. html的一些基本属性介绍

    一.html的属性类型: 1.常见标签属性: a.<h1>:align对其方式      例如:<h1  align="right"> hhhhh</ ...