验证码处理

验证码破解平台

http://www.yundama.com/

http://www.chaojiying.com/

我们用超级鹰的验证码破解平台,来破解云打码的登陆验证码

登陆超级鹰官网,需要先充值,充值后下载开发文档

然后生成一个软件 ID

根据提示把自己的账号密码和软件 ID 填上

chaojiying.py

#!/usr/bin/env python
# coding:utf-8

import requests
from hashlib import md5

class Chaojiying_Client(object):

    def __init__(self, username, password, soft_id):
        self.username = username
        password =  password.encode('utf8')
        self.password = md5(password).hexdigest()
        self.soft_id = soft_id
        self.base_params = {
            'user': self.username,
            'pass2': self.password,
            'softid': self.soft_id,
        }
        self.headers = {
            'Connection': 'Keep-Alive',
            'User-Agent': 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)',
        }

    def PostPic(self, im, codetype):
        """
        im: 图片字节
        codetype: 题目类型 参考 http://www.chaojiying.com/price.html
        """
        params = {
            'codetype': codetype,
        }
        params.update(self.base_params)
        files = {'userfile': ('a.jpg', im)}
        r = requests.post('http://upload.chaojiying.net/Upload/Processing.php', data=params, files=files, headers=self.headers)
        return r.json()

    def ReportError(self, im_id):
        """
        im_id:报错题目的图片ID
        """
        params = {
            'id': im_id,
        }
        params.update(self.base_params)
        r = requests.post('http://upload.chaojiying.net/Upload/ReportError.php', data=params, headers=self.headers)
        return r.json()


if __name__ == '__main__':
    chaojiying = Chaojiying_Client('leiting', '******', 'b87e36b14402ae798f63d0c25c5daf19')	#用户中心>>软件ID 生成一个替换 ******
    im = open('a.jpg', 'rb').read()													#本地图片文件路径 来替换 a.jpg 有时WIN系统须要//
    print (chaojiying.PostPic(im, 1902))												#1902 验证码类型  官方网站>>价格体系 3.4+版 print 后要加()


破解云打码登陆验证码.py

import requests
from bs4 import BeautifulSoup


url = 'http://www.yundama.com/'

HEADERS = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36',
    }

res = requests.get(url, headers=HEADERS).text

soup = BeautifulSoup(res, 'lxml')
img_url = 'http://www.yundama.com/' + soup.find(id='verifyImg')['src']
img_content = requests.get(img_url)
with open('yzm.png', 'wb') as f:
    f.write(img_content.content)

from chaojiying import Chaojiying_Client

chaojiying = Chaojiying_Client('leiting', '******', 'b87e36b14402ae798f63d0c25c5daf19')	#用户中心>>软件ID 生成一个替换 ******
im = open('yzm.png', 'rb').read()													#本地图片文件路径 来替换 a.jpg 有时WIN系统须要//
img_data_dic = chaojiying.PostPic(im, 1902)
img_data = img_data_dic['pic_str']
print(img_data)

然后将打印出来的 验证码 和图片对比

发现正确率还是可以的

原文地址:https://www.cnblogs.com/kai-/p/12661225.html