|
|
|
@ -28,7 +28,7 @@ sys.setdefaultencoding('utf-8')
|
|
|
|
|
|
|
|
|
|
class select:
|
|
|
|
|
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.aotu_code_type = _get_yaml()["aotu_code_type"]
|
|
|
|
|
self.order_request_params = {} # 订单提交时的参数
|
|
|
|
@ -60,10 +60,9 @@ class select:
|
|
|
|
|
ticke_peoples = ticket_info_config["set"]["ticke_peoples"]
|
|
|
|
|
select_refresh_interval = ticket_info_config["select_refresh_interval"]
|
|
|
|
|
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"]
|
|
|
|
|
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,
|
|
|
|
|
to_station,
|
|
|
|
@ -73,11 +72,10 @@ class select:
|
|
|
|
|
",".join(ticke_peoples),
|
|
|
|
|
select_refresh_interval,
|
|
|
|
|
",".join(station_trains),
|
|
|
|
|
expect_refresh_interval,
|
|
|
|
|
ticket_black_list_time,
|
|
|
|
|
)
|
|
|
|
|
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):
|
|
|
|
|
return self.order_request_params
|
|
|
|
@ -154,7 +152,10 @@ class select:
|
|
|
|
|
识别验证码
|
|
|
|
|
: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):
|
|
|
|
|
"""
|
|
|
|
@ -393,6 +394,8 @@ class select:
|
|
|
|
|
if 'data' in checkOrderInfo:
|
|
|
|
|
if "ifShowPassCode" in checkOrderInfo["data"] and checkOrderInfo["data"]["ifShowPassCode"] == "Y":
|
|
|
|
|
is_need_code = True
|
|
|
|
|
t = threading.Thread(target=self.callRandCode())
|
|
|
|
|
t.start()
|
|
|
|
|
if self.getQueueCount(train_no, set_type, is_need_code):
|
|
|
|
|
return True
|
|
|
|
|
if "ifShowPassCode" in checkOrderInfo["data"] and checkOrderInfo['data']['submitStatus'] is True:
|
|
|
|
@ -459,6 +462,21 @@ class select:
|
|
|
|
|
else:
|
|
|
|
|
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):
|
|
|
|
|
"""
|
|
|
|
|
模拟提交订单是确认按钮,参数获取方法还是get_ticketInfoForPassengerForm 中获取
|
|
|
|
@ -483,31 +501,31 @@ class select:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
for i in range(3):
|
|
|
|
|
if is_node_code:
|
|
|
|
|
|
|
|
|
|
print("正在使用自动识别验证码功能")
|
|
|
|
|
checkRandCodeAnsyn = self.confUrl["checkRandCodeAnsyn"]["req_url"]
|
|
|
|
|
codeImgByOrder = self.confUrl["codeImgByOrder"]["req_url"]
|
|
|
|
|
self.login.readImg(codeImgByOrder)
|
|
|
|
|
randCode = self.login.getRandCode()
|
|
|
|
|
randData = {
|
|
|
|
|
"randCode": randCode,
|
|
|
|
|
"rand": "randp",
|
|
|
|
|
"_json_att": None,
|
|
|
|
|
"REPEAT_SUBMIT_TOKEN": self.get_token()
|
|
|
|
|
}
|
|
|
|
|
fresult = self.httpClint.send(checkRandCodeAnsyn, randData) # 校验验证码是否正确
|
|
|
|
|
checkcode = fresult['data']['msg']
|
|
|
|
|
if checkcode == 'TRUE':
|
|
|
|
|
print("验证码通过,正在提交订单")
|
|
|
|
|
data['randCode'] = randCode
|
|
|
|
|
break
|
|
|
|
|
else:
|
|
|
|
|
print ("验证码有误, 接口返回{0} 第{1}次尝试重试".format(fresult, i))
|
|
|
|
|
else:
|
|
|
|
|
print("不需要验证码")
|
|
|
|
|
break
|
|
|
|
|
if is_node_code:
|
|
|
|
|
print("正在使用自动识别验证码功能")
|
|
|
|
|
while True:
|
|
|
|
|
if self.randCode:
|
|
|
|
|
checkcode = self.checkRandCodeAnsyn(self.randCode)
|
|
|
|
|
if checkcode == 'TRUE':
|
|
|
|
|
print("验证码通过,正在提交订单")
|
|
|
|
|
data['randCode'] = self.randCode
|
|
|
|
|
self.randCode = ""
|
|
|
|
|
break
|
|
|
|
|
else:
|
|
|
|
|
for i in range(3):
|
|
|
|
|
codeImgByOrder = self.confUrl["codeImgByOrder"]["req_url"]
|
|
|
|
|
self.login.readImg(codeImgByOrder)
|
|
|
|
|
randCode = self.login.getRandCode()
|
|
|
|
|
if checkcode == 'TRUE':
|
|
|
|
|
print("验证码通过,正在提交订单")
|
|
|
|
|
data['randCode'] = randCode
|
|
|
|
|
break
|
|
|
|
|
else:
|
|
|
|
|
print ("验证码有误, {0}次尝试重试".format(i+1))
|
|
|
|
|
print("验证码超过限定次数3次,放弃此次订票机会!")
|
|
|
|
|
break
|
|
|
|
|
else:
|
|
|
|
|
print("不需要验证码")
|
|
|
|
|
checkQueueOrderResult = self.httpClint.send(checkQueueOrderUrl, data)
|
|
|
|
|
if "status" in checkQueueOrderResult and checkQueueOrderResult["status"]:
|
|
|
|
|
c_data = checkQueueOrderResult["data"] if "data" in checkQueueOrderResult else {}
|
|
|
|
|