Python之超级鹰处理验证码
Python之超级鹰处理验证码
登录网站为:
研究生教育信息管理系统
main里是主要内容
其他部分为超级鹰官网提供
传入用户名,密码,及软件id
复制import requests
from hashlib import md5
from selenium.webdriver import Chrome
import time
from selenium.webdriver import ActionChains
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': ('ccc.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__':
web = Chrome()
web.get('https://202.199.113.11/login.html')
web.maximize_window()
web.find_element_by_xpath('//*[@id="details-button"]').click()
web.find_element_by_xpath('//*[@id="proceed-link"]').click()
web.find_element_by_xpath('//*[@id="account"]').send_keys('用户名')
web.find_element_by_xpath('//*[@id="pwd"]').send_keys('密码')
img=web.find_element_by_xpath('//*[@id="VerifyCode"]').screenshot_as_png
# 处理验证码
chaojiying = Chaojiying_Client('13841055783', 's88347611487561', '923221') #用户中心>>软件ID 生成一个替换 96001
security_code=chaojiying.PostPic(img, 1902)
print(security_code)
web.find_element_by_xpath('//*[@id="code"]').send_keys(security_code['pic_str'])
web.find_element_by_xpath('//*[@id="login_btn"]').click()
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)