pyhton验证码识别

1、PIL 下载地址: PIL-1.1.7.win-amd64-py2.7.exe

2、tesseract-ocr下载地址: tesseract-ocr-setup-3.02.02.exe

3、pytesseract安装 直接使用pip install pytesseract安装即可,或者使用easy_install pytesseract

下载链接:http://pan.baidu.com/s/1hrVRHYG

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
 
'''
 
try:
    import pytesseract
    from PIL import Image
except ImportError:
    print '模块导入错误,请使用pip安装,pytesseract依赖以下库:'
    print 'http://www.lfd.uci.edu/~gohlke/pythonlibs/#pil'
    print 'http://code.google.com/p/tesseract-ocr/'
    raise SystemExit
  
image = Image.open('vcode.png')
vcode = pytesseract.image_to_string(image)
print vcode
'''
 
import pytesseract
from PIL import Image
import requests
 
def Vercode():
    url = "http://www.xxxx"
    header = {"user_agent":"Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)"}
    r =requests.get(url,headers=header,timeout=5)
    with open('vcode.jpg','wb') as pic:
        pic.write(r.content)
    im = pytesseract.image_to_string(Image.open('vcode.jpg'))
    im = im.replace(' ', '')
    if im != '':
        return im
    else:
        return Vercode()
print Vcode()

 

参考文章:

  [python]python验证码识别 https://www.waitalone.cn/python-php-ocr.html

  网络信息安全攻防学习平台脚本关过关攻略 https://www.waitalone.cn/security-scripts-game.html

  http://hackinglab.cn/ShowQues.php?type=scripts

posted @   Bypass  阅读(500)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫
点击右上角即可分享
微信分享提示