代码拉取完成,页面将自动刷新
1.完善需求文档
2.使用打码平台识别12306验证码
1.5/2
import re
import base64
headers={
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36',
# 'Connection': 'keep-alive',
}
s=requests.Session()
url='https://kyfw.12306.cn/otn/resources/login.html'
url='https://kyfw.12306.cn/passport/captcha/captcha-image64?login_site=E&module=login&rand=sjrand&1566980745733&callback=jQuery1910500591329861616_1566980496040&_=1566980496044'
s.get(url,headers=headers)
page_text=s.get(url,headers=headers).text
print(page_text)
b64_image = re.findall(r'{"image":"(.*?)",', page_text, re.S)[0]
image_data = base64.b64decode(b64_image)
with open(r"./12306.jpg", "wb") as f:
f.write(image_data)
# tree=etree.HTML(page_text)
# src=tree.xpath('//*[@id="J-loginImg"]/@src')[0]
img_text=getCodeImgText('./12306.jpg',9004)
print('识别内容',img_text)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1/2
1/2
1/2
1/2
1/2
80%
1/2
1/2
1/2
2/2
1/2
1/2
1/2
1/2
1/2
1/2
1/2
1.5/2
登录 后才可以发表评论