|
|
@ -28,7 +28,7 @@ sys.setdefaultencoding('utf-8')
|
|
|
|
|
|
|
|
|
|
|
|
class select:
|
|
|
|
class select:
|
|
|
|
def __init__(self):
|
|
|
|
def __init__(self):
|
|
|
|
self.from_station, self.to_station, self.station_dates, self._station_seat, self.is_more_ticket, self.ticke_peoples, self.select_refresh_interval, self.station_trains, self.expect_refresh_interval, self.ticket_black_list_time = self.get_ticket_info()
|
|
|
|
self.from_station, self.to_station, self.station_dates, self._station_seat, self.is_more_ticket, self.ticke_peoples, self.select_refresh_interval, self.station_trains, self.ticket_black_list_time = self.get_ticket_info()
|
|
|
|
self.is_aotu_code = _get_yaml()["is_aotu_code"]
|
|
|
|
self.is_aotu_code = _get_yaml()["is_aotu_code"]
|
|
|
|
self.aotu_code_type = _get_yaml()["aotu_code_type"]
|
|
|
|
self.aotu_code_type = _get_yaml()["aotu_code_type"]
|
|
|
|
self.order_request_params = {} # 订单提交时的参数
|
|
|
|
self.order_request_params = {} # 订单提交时的参数
|
|
|
@ -60,10 +60,9 @@ class select:
|
|
|
|
ticke_peoples = ticket_info_config["set"]["ticke_peoples"]
|
|
|
|
ticke_peoples = ticket_info_config["set"]["ticke_peoples"]
|
|
|
|
select_refresh_interval = ticket_info_config["select_refresh_interval"]
|
|
|
|
select_refresh_interval = ticket_info_config["select_refresh_interval"]
|
|
|
|
station_trains = ticket_info_config["set"]["station_trains"]
|
|
|
|
station_trains = ticket_info_config["set"]["station_trains"]
|
|
|
|
expect_refresh_interval = ticket_info_config["expect_refresh_interval"]
|
|
|
|
|
|
|
|
ticket_black_list_time = ticket_info_config["ticket_black_list_time"]
|
|
|
|
ticket_black_list_time = ticket_info_config["ticket_black_list_time"]
|
|
|
|
print "*"*20
|
|
|
|
print "*"*20
|
|
|
|
print "当前配置:出发站:{0}\n到达站:{1}\n乘车日期:{2}\n坐席:{3}\n是否有票自动提交:{4}\n乘车人:{5}\n刷新间隔:{6}\n候选购买车次:{7}\n未开始刷票间隔时间:{8}\n僵尸票关小黑屋时长:{9}\n".format\
|
|
|
|
print "当前配置:出发站:{0}\n到达站:{1}\n乘车日期:{2}\n坐席:{3}\n是否有票自动提交:{4}\n乘车人:{5}\n刷新间隔:{6}\n候选购买车次:{7}\n僵尸票关小黑屋时长:{8}\n".format\
|
|
|
|
(
|
|
|
|
(
|
|
|
|
from_station,
|
|
|
|
from_station,
|
|
|
|
to_station,
|
|
|
|
to_station,
|
|
|
@ -73,11 +72,10 @@ class select:
|
|
|
|
",".join(ticke_peoples),
|
|
|
|
",".join(ticke_peoples),
|
|
|
|
select_refresh_interval,
|
|
|
|
select_refresh_interval,
|
|
|
|
",".join(station_trains),
|
|
|
|
",".join(station_trains),
|
|
|
|
expect_refresh_interval,
|
|
|
|
|
|
|
|
ticket_black_list_time,
|
|
|
|
ticket_black_list_time,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
print "*"*20
|
|
|
|
print "*"*20
|
|
|
|
return from_station, to_station, station_dates, set_type, is_more_ticket, ticke_peoples, select_refresh_interval, station_trains, expect_refresh_interval, ticket_black_list_time
|
|
|
|
return from_station, to_station, station_dates, set_type, is_more_ticket, ticke_peoples, select_refresh_interval, station_trains, ticket_black_list_time
|
|
|
|
|
|
|
|
|
|
|
|
def get_order_request_params(self):
|
|
|
|
def get_order_request_params(self):
|
|
|
|
return self.order_request_params
|
|
|
|
return self.order_request_params
|
|
|
@ -154,7 +152,10 @@ class select:
|
|
|
|
识别验证码
|
|
|
|
识别验证码
|
|
|
|
:return:
|
|
|
|
:return:
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
self.randCode = self.login.getRandCode()
|
|
|
|
while True:
|
|
|
|
|
|
|
|
if self.is_aotu_code:
|
|
|
|
|
|
|
|
self.randCode = self.login.getRandCode()
|
|
|
|
|
|
|
|
self.is_aotu_code = False
|
|
|
|
|
|
|
|
|
|
|
|
def getRepeatSubmitToken(self):
|
|
|
|
def getRepeatSubmitToken(self):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -393,6 +394,8 @@ class select:
|
|
|
|
if 'data' in checkOrderInfo:
|
|
|
|
if 'data' in checkOrderInfo:
|
|
|
|
if "ifShowPassCode" in checkOrderInfo["data"] and checkOrderInfo["data"]["ifShowPassCode"] == "Y":
|
|
|
|
if "ifShowPassCode" in checkOrderInfo["data"] and checkOrderInfo["data"]["ifShowPassCode"] == "Y":
|
|
|
|
is_need_code = True
|
|
|
|
is_need_code = True
|
|
|
|
|
|
|
|
t = threading.Thread(target=self.callRandCode())
|
|
|
|
|
|
|
|
t.start()
|
|
|
|
if self.getQueueCount(train_no, set_type, is_need_code):
|
|
|
|
if self.getQueueCount(train_no, set_type, is_need_code):
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
if "ifShowPassCode" in checkOrderInfo["data"] and checkOrderInfo['data']['submitStatus'] is True:
|
|
|
|
if "ifShowPassCode" in checkOrderInfo["data"] and checkOrderInfo['data']['submitStatus'] is True:
|
|
|
@ -459,6 +462,21 @@ class select:
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
print("未知错误 {0}".format("".join(getQueueCountResult)))
|
|
|
|
print("未知错误 {0}".format("".join(getQueueCountResult)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def checkRandCodeAnsyn(self, randCode):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
识别验证码
|
|
|
|
|
|
|
|
:return: 识别结果
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
checkRandCodeAnsyn = self.confUrl["checkRandCodeAnsyn"]["req_url"]
|
|
|
|
|
|
|
|
randData = {
|
|
|
|
|
|
|
|
"randCode": randCode,
|
|
|
|
|
|
|
|
"rand": "randp",
|
|
|
|
|
|
|
|
"_json_att": None,
|
|
|
|
|
|
|
|
"REPEAT_SUBMIT_TOKEN": self.get_token()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fresult = self.httpClint.send(checkRandCodeAnsyn, randData) # 校验验证码是否正确
|
|
|
|
|
|
|
|
return fresult['data']['msg']
|
|
|
|
|
|
|
|
|
|
|
|
def checkQueueOrder(self, is_node_code=False):
|
|
|
|
def checkQueueOrder(self, is_node_code=False):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
模拟提交订单是确认按钮,参数获取方法还是get_ticketInfoForPassengerForm 中获取
|
|
|
|
模拟提交订单是确认按钮,参数获取方法还是get_ticketInfoForPassengerForm 中获取
|
|
|
@ -483,31 +501,31 @@ class select:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
for i in range(3):
|
|
|
|
if is_node_code:
|
|
|
|
if is_node_code:
|
|
|
|
print("正在使用自动识别验证码功能")
|
|
|
|
|
|
|
|
while True:
|
|
|
|
print("正在使用自动识别验证码功能")
|
|
|
|
if self.randCode:
|
|
|
|
checkRandCodeAnsyn = self.confUrl["checkRandCodeAnsyn"]["req_url"]
|
|
|
|
checkcode = self.checkRandCodeAnsyn(self.randCode)
|
|
|
|
codeImgByOrder = self.confUrl["codeImgByOrder"]["req_url"]
|
|
|
|
if checkcode == 'TRUE':
|
|
|
|
self.login.readImg(codeImgByOrder)
|
|
|
|
print("验证码通过,正在提交订单")
|
|
|
|
randCode = self.login.getRandCode()
|
|
|
|
data['randCode'] = self.randCode
|
|
|
|
randData = {
|
|
|
|
self.randCode = ""
|
|
|
|
"randCode": randCode,
|
|
|
|
break
|
|
|
|
"rand": "randp",
|
|
|
|
else:
|
|
|
|
"_json_att": None,
|
|
|
|
for i in range(3):
|
|
|
|
"REPEAT_SUBMIT_TOKEN": self.get_token()
|
|
|
|
codeImgByOrder = self.confUrl["codeImgByOrder"]["req_url"]
|
|
|
|
}
|
|
|
|
self.login.readImg(codeImgByOrder)
|
|
|
|
fresult = self.httpClint.send(checkRandCodeAnsyn, randData) # 校验验证码是否正确
|
|
|
|
randCode = self.login.getRandCode()
|
|
|
|
checkcode = fresult['data']['msg']
|
|
|
|
if checkcode == 'TRUE':
|
|
|
|
if checkcode == 'TRUE':
|
|
|
|
print("验证码通过,正在提交订单")
|
|
|
|
print("验证码通过,正在提交订单")
|
|
|
|
data['randCode'] = randCode
|
|
|
|
data['randCode'] = randCode
|
|
|
|
break
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
print ("验证码有误, {0}次尝试重试".format(i+1))
|
|
|
|
print ("验证码有误, 接口返回{0} 第{1}次尝试重试".format(fresult, i))
|
|
|
|
print("验证码超过限定次数3次,放弃此次订票机会!")
|
|
|
|
else:
|
|
|
|
break
|
|
|
|
print("不需要验证码")
|
|
|
|
else:
|
|
|
|
break
|
|
|
|
print("不需要验证码")
|
|
|
|
checkQueueOrderResult = self.httpClint.send(checkQueueOrderUrl, data)
|
|
|
|
checkQueueOrderResult = self.httpClint.send(checkQueueOrderUrl, data)
|
|
|
|
if "status" in checkQueueOrderResult and checkQueueOrderResult["status"]:
|
|
|
|
if "status" in checkQueueOrderResult and checkQueueOrderResult["status"]:
|
|
|
|
c_data = checkQueueOrderResult["data"] if "data" in checkQueueOrderResult else {}
|
|
|
|
c_data = checkQueueOrderResult["data"] if "data" in checkQueueOrderResult else {}
|
|
|
|