修复登录失效问题 #253
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
# coding=utf-8
|
||||
import copy
|
||||
import random
|
||||
import time
|
||||
|
||||
|
||||
def getPassCodeNewOrderAndLogin(session, imgType):
|
||||
@@ -35,3 +34,41 @@ def getPassCodeNewOrderAndLogin(session, imgType):
|
||||
return result
|
||||
except OSError:
|
||||
print(u"验证码下载失败,可能ip被封,确认请手动请求: {0}".format(codeImgUrl))
|
||||
|
||||
|
||||
def getPassCodeNewOrderAndLogin1(session, imgType):
|
||||
"""
|
||||
获取验证码2
|
||||
:param session:
|
||||
:param imgType:
|
||||
:return:
|
||||
"""
|
||||
if imgType == "login":
|
||||
codeImgUrl = copy.deepcopy(session.urls["getCodeImg1"])
|
||||
codeImgUrl["req_url"] = codeImgUrl["req_url"].format(random.random())
|
||||
else:
|
||||
codeImgUrl = copy.deepcopy(session.urls["codeImgByOrder"])
|
||||
codeImgUrl["req_url"] = codeImgUrl["req_url"].format(random.random())
|
||||
print(u"下载验证码...")
|
||||
img_path = './tkcode.png'
|
||||
codeImgUrlRsp = session.httpClint.send(codeImgUrl)
|
||||
result = eval(codeImgUrlRsp.split("(")[1].split(")")[0]).get("image")
|
||||
try:
|
||||
if isinstance(result, dict):
|
||||
print(u"下载验证码失败, 请手动检查是否ip被封,或者重试,请求地址:https://kyfw.12306.cn{}".format(codeImgUrl.get("req_url")))
|
||||
return False
|
||||
else:
|
||||
print(u"下载验证码成功")
|
||||
try:
|
||||
with open(img_path, 'wb', encoding="utf-8") as img:
|
||||
img.write(result)
|
||||
except Exception:
|
||||
with open(img_path, 'wb') as img:
|
||||
img.write(result)
|
||||
return result
|
||||
except OSError:
|
||||
print(u"验证码下载失败,可能ip被封,确认请手动请求: {0}".format(codeImgUrl))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
pass
|
||||
|
||||
@@ -23,7 +23,8 @@ def getRandCode(is_auto_code, auto_code_type, result):
|
||||
if auto_code_type == 2:
|
||||
rc = RClient(_get_yaml()["auto_code_account"]["user"], _get_yaml()["auto_code_account"]["pwd"])
|
||||
# im = open('./tkcode', 'rb').read()
|
||||
Result = rc.rk_create(result, 6113)
|
||||
# Result = rc.rk_create(result, 6113)
|
||||
Result = rc.rk_create_base64(result, 6113)
|
||||
if "Result" in Result:
|
||||
return codexy(Ofset=",".join(list(Result["Result"])), is_raw_input=False)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user