mirror of https://github.com/testerSunshine/12306
增加无需验证码登录接口
parent
85b2e48330
commit
b4c6c4f858
|
@ -337,18 +337,6 @@ urls = {
|
|||
"is_logger": True,
|
||||
"is_json": True,
|
||||
},
|
||||
"loginAysnSuggest": { # 快速订单排队
|
||||
"req_url": "/otn/login/loginAysnSuggest",
|
||||
"req_type": "post",
|
||||
"Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
|
||||
"Content-Type": 1,
|
||||
"Host": "kyfw.12306.cn",
|
||||
"re_try": 10,
|
||||
"re_time": 0.01,
|
||||
"s_time": 0.1,
|
||||
"is_logger": True,
|
||||
"is_json": True,
|
||||
},
|
||||
"Pushbear": { # push通知
|
||||
"req_url": "/sub",
|
||||
"req_type": "post",
|
||||
|
@ -368,5 +356,93 @@ urls = {
|
|||
"cdn_list": {
|
||||
"req_url": "http://ping.chinaz.com/iframe.ashx?t=ping&callback=jQuery111304824429956769827_{}".format(int(round(time.time() * 1000))),
|
||||
"req_type": "post"
|
||||
}
|
||||
},
|
||||
|
||||
"TPLINK": { # TPLINK请求地址
|
||||
"req_url": "/",
|
||||
"req_type": "post",
|
||||
"Referer": "",
|
||||
"Content-Type": 1,
|
||||
"Host": "192.168.0.1",
|
||||
"re_try": 10,
|
||||
"re_time": 0.01,
|
||||
"s_time": 0.1,
|
||||
"is_logger": False,
|
||||
"is_json": True,
|
||||
"httpType": "http"
|
||||
},
|
||||
"TPds": { # TPLINK路由器内部切换地址
|
||||
"req_url": "/stok={}/ds",
|
||||
"req_type": "post",
|
||||
"Referer": "",
|
||||
"Content-Type": 1,
|
||||
"Host": "192.168.0.1",
|
||||
"re_try": 10,
|
||||
"re_time": 0.01,
|
||||
"s_time": 0.1,
|
||||
"is_logger": False,
|
||||
"is_json": True,
|
||||
"httpType": "http"
|
||||
},
|
||||
"xiaomiHome": { # 小米路由器登录
|
||||
"req_url": "/cgi-bin/luci/web",
|
||||
"req_type": "get",
|
||||
"Referer": "",
|
||||
"Content-Type": 1,
|
||||
"Host": "192.168.31.1",
|
||||
"re_try": 10,
|
||||
"re_time": 0.01,
|
||||
"s_time": 0.1,
|
||||
"is_logger": False,
|
||||
"is_json": False,
|
||||
"httpType": "http"
|
||||
},
|
||||
"xiaomi": { # 小米路由器登录
|
||||
"req_url": "/cgi-bin/luci/api/xqsystem/login",
|
||||
"req_type": "post",
|
||||
"Referer": "",
|
||||
"Content-Type": 1,
|
||||
"Host": "192.168.31.1",
|
||||
"re_try": 10,
|
||||
"re_time": 0.01,
|
||||
"s_time": 0.1,
|
||||
"is_logger": False,
|
||||
"is_json": True,
|
||||
"httpType": "http"
|
||||
},
|
||||
"loginHtml": { # 登录接口2
|
||||
"req_url": "/otn/resources/login.html",
|
||||
"req_type": "get",
|
||||
"Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
|
||||
"Host": "kyfw.12306.cn",
|
||||
"re_try": 10,
|
||||
"re_time": 0.3,
|
||||
"s_time": 0.1,
|
||||
"is_logger": True,
|
||||
"is_json": True,
|
||||
},
|
||||
"loginConf": { # 登录接口2
|
||||
"req_url": "/otn/login/conf",
|
||||
"req_type": "post",
|
||||
"Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
|
||||
"Host": "kyfw.12306.cn",
|
||||
"re_try": 10,
|
||||
"re_time": 0.3,
|
||||
"s_time": 0.1,
|
||||
"is_logger": True,
|
||||
"is_json": True,
|
||||
},
|
||||
"loginAysnSuggest": { # 登录接口2
|
||||
"req_url": "/otn/login/loginAysnSuggest",
|
||||
"req_type": "post",
|
||||
"Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
|
||||
"Host": "kyfw.12306.cn",
|
||||
"re_try": 10,
|
||||
"re_time": 0.3,
|
||||
"s_time": 0.1,
|
||||
"is_logger": True,
|
||||
"is_json": True,
|
||||
},
|
||||
|
||||
|
||||
}
|
|
@ -4,6 +4,8 @@ from time import sleep
|
|||
from config.ticketConf import _get_yaml
|
||||
from inter.GetPassCodeNewOrderAndLogin import getPassCodeNewOrderAndLogin
|
||||
from inter.GetRandCode import getRandCode
|
||||
from inter.LoginAysnSuggest import loginAysnSuggest
|
||||
from inter.LoginConf import loginConf
|
||||
from myException.UserPasswordException import UserPasswordException
|
||||
from myException.balanceException import balanceException
|
||||
|
||||
|
@ -113,17 +115,24 @@ class GoLogin:
|
|||
raise UserPasswordException(u"温馨提示: 用户名或者密码为空,请仔细检查")
|
||||
login_num = 0
|
||||
while True:
|
||||
result = getPassCodeNewOrderAndLogin(session=self.session, imgType="login")
|
||||
if not result:
|
||||
continue
|
||||
self.randCode = getRandCode(self.is_auto_code, self.auto_code_type, result)
|
||||
login_num += 1
|
||||
self.auth()
|
||||
if self.codeCheck():
|
||||
uamtk = self.baseLogin(user, passwd)
|
||||
if uamtk:
|
||||
self.getUserName(uamtk)
|
||||
break
|
||||
if loginConf(self.session):
|
||||
result = getPassCodeNewOrderAndLogin(session=self.session, imgType="login")
|
||||
if not result:
|
||||
continue
|
||||
self.randCode = getRandCode(self.is_auto_code, self.auto_code_type, result)
|
||||
login_num += 1
|
||||
self.auth()
|
||||
if self.codeCheck():
|
||||
uamtk = self.baseLogin(user, passwd)
|
||||
if uamtk:
|
||||
self.getUserName(uamtk)
|
||||
break
|
||||
else:
|
||||
loginAysnSuggest(self.session, username=user, password=passwd)
|
||||
login_num += 1
|
||||
break
|
||||
|
||||
|
||||
|
||||
# if __name__ == "__main__":
|
||||
# # main()
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
# coding=utf-8
|
||||
from config.urlConf import urls
|
||||
|
||||
|
||||
def loginAysnSuggest(session, username, password):
|
||||
"""
|
||||
登录接口
|
||||
ps: 不需要验证码
|
||||
:return:
|
||||
"""
|
||||
loginAysnSuggestUrls = urls.get("loginAysnSuggest")
|
||||
data = {
|
||||
"loginUserDTO.user_name": username,
|
||||
"userDTO.password": password
|
||||
}
|
||||
loginAysnSuggestRsp = session.httpClint.send(urls=loginAysnSuggestUrls, data=data)
|
||||
if loginAysnSuggestRsp and loginAysnSuggestRsp.get("httpstatus") is 200 and loginAysnSuggestRsp.get("data", {}).get("loginCheck") == "Y":
|
||||
print(u"登录成功")
|
||||
else:
|
||||
print(u"登录失败, {0} {1}".format("".join(loginAysnSuggestRsp.get("messages")), loginAysnSuggestRsp.get("validateMessages")))
|
|
@ -0,0 +1,22 @@
|
|||
# coding=utf-8
|
||||
from config.urlConf import urls
|
||||
|
||||
|
||||
def loginConf(session):
|
||||
"""
|
||||
判断登录是否需要验证码
|
||||
:param session:
|
||||
:return:
|
||||
"""
|
||||
loginConfUrl = urls.get("loginConf")
|
||||
loginConfRsp = session.httpClint.send(urls=loginConfUrl, data={})
|
||||
if loginConfRsp and loginConfRsp.get("data", {}).get("is_login_passCode") == "N":
|
||||
print(u"不需要验证码")
|
||||
return False
|
||||
else:
|
||||
print(u"需要验证码")
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
pass
|
Loading…
Reference in New Issue