import time
import requests
import base64
from PIL import Image
import ddddocr
def get_captcha():
headers = {
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Connection': 'keep-alive',
'Origin': 'https://openmao.panchuang.net',
'Referer': 'https://openmao.panchuang.net/',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-site',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
'sec-ch-ua': '"Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
}
response = requests.get('https://mapi.panchuang.net/api/user/captchaImage', headers=headers)
print(response.text)
return response.json()
def decode_base64_to_img(base64_str):
img_data = base64.b64decode(base64_str)
with open('image.jpg', 'wb') as f:
f.write(img_data)
img = Image.open('image.jpg')
def verification():
# 验证码识别
ocr = ddddocr.DdddOcr()
with open('image.jpg', 'rb') as f:
img_bytes = f.read()
res = ocr.classification(img_bytes)
print(res)
text = res[:3] # 提取前三位子串
print(text) # 输出:8*4
if "+" in text or "-" in text or "*" in text or "/" in text:
print("字符串中包含 +、-、* 或 / 符号")
first_char = text[0] # 第一位字符
last_char = text[-1] # 最后一位字符
print("第一位字符:", first_char)
print("最后一位字符:", last_char)
if "+" in text:
result=int(first_char)+int(last_char)
if "-" in text:
result=int(first_char)-int(last_char)
if "*" in text:
result=int(first_char)*int(last_char)
if "/" in text:
result=int(first_char)/int(last_char)
print(f"计算结果为{result}")
else:
print("字符串中不包含 +、-、* 或 / 符号")
result = get_captcha()
global uuid
uuid = result['uuid'];
# 转换本地
decode_base64_to_img(result['img'])
verification()
if __name__ == '__main__':
# 获取验证码
global uuid
result=get_captcha()
# 转换本地
uuid=result['uuid'];
decode_base64_to_img(result['img'])
time.sleep(1)
# 提取数字
result_num = verification()
headers = {
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Connection': 'keep-alive',
'Content-Type': 'application/json',
'Origin': 'https://openmao.panchuang.net',
'Referer': 'https://openmao.panchuang.net/',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-site',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
'sec-ch-ua': '"Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
}
print(uuid)
json_data = {
'username': '15368666279',
'password': 'qwer4399zy',
'loginTypeEnum': 'ACCOUNT',
'code': result_num,
'uuid': uuid,
}
# response = requests.post('https://mapi.panchuang.net/api/user/login', headers=headers, json=json_data)
# print(response.text)
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
获取Chatgpt3.5免费接口文末付代码(过Authorization认证)Ddddocr识别Ocr过开放猫验证码,这里仅有过验证码demo,会点代码就能看懂,结合我的文章,自己可以拿到python版的Chatgpt3.5接口 文章详情:https://taila.blog.csdn.net/article/details/130199605 https://taila.blog.csdn.net/article/details/130298338
资源推荐
资源详情
资源评论




























收起资源包目录







共 6 条
- 1
资源评论

- S_G___2023-12-14发现一个宝藏资源,资源有很高的参考价值,赶紧学起来~
- diandian57622024-05-31超级好的资源,很值得参考学习,对我启发很大,支持!

园游会永不打烊.
- 粉丝: 1w+
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 企业投资网站项目建设方案.doc
- 《大学计算机基础》课程网上教学系统的设计实现开题分析方案.doc
- 装配式建筑PC施工费讲解.ppt
- 海萨2x600mw锅炉主要施工方案.doc
- 计算-20以内加减法.doc
- 文献分析工具hiscite和bibexcel的使用.ppt
- 园林绿化造价计算题.doc
- Windows平台下snort入侵检测系统安装.doc
- Weblogic安装部署手册.doc
- 实验4-基于MATLAB的FIR数字滤波器设计.doc
- 期高层01高层建筑结构概念设计.docx
- 模板工程质量控制程序图.doc
- 职称英语考试——理工c-secret.docx
- CAD室内设计师考证课件-(第五单元).ppt
- 项目竣工验收审批流程.docx
- 核心素养引领下的高等数学信息化教材开发研究.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
