一 简介
直接点击图中符合要求的图。所有的答案都正确,验证才会成功,如果有一个答案错误,验证就会失败。
二 目标
用程序来识别并通过点触验证码的验证。
三 了解点触验证码
12306官网的验证码样式:
四 超级鹰注册账号
https://www.chaojiying.com/user/reg
注册用户:cakin24
验证码类型参考:https://www.chaojiying.com/price.html
五 代码
1 Chaojiying.py
import requests
from hashlib import md5
class Chaojiying(object):
def __init__(self, username, password, soft_id):
self.username = username
self.password = md5(password.encode('utf-8')).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 post_pic(self, im, codetype):
"""
im: 图片字节
codetype: 题目类型 参考 http://www.chaojiying.com/pr