优化订票逻辑

pull/66/head
wenxianping 6 years ago
parent 69a3b44236
commit 8c7804dd4c

@ -243,7 +243,7 @@ class select:
self.ticke_peoples)
sor.sendSubmitOrderRequest()
else:
random_time = round(random.uniform(1, 3), 2)
random_time = round(random.uniform(0.5, 0.5), 2)
time.sleep(random_time)
print u"正在第{0}次查询 随机停留时长:{6} 乘车日期: {1} 车次:{2} 查询无票 cdn轮询IP{4}当前cdn总数{5} 总耗时:{3}ms".format(num,
",".join(

@ -78,22 +78,23 @@ class getQueueCount:
if "countT" in getQueueCountResult["data"]:
ticket = getQueueCountResult["data"]["ticket"]
ticket_split = sum(map(conversion_int, ticket.split(","))) if ticket.find(",") != -1 else ticket
countT = getQueueCountResult["data"]["countT"]
if int(countT) is 0:
print(u"排队成功, 当前余票还剩余: {0}".format(ticket_split))
csf = confirmSingleForQueue(self.session, self.ifShowPassCodeTime, self.is_need_code, self.token,
self.set_type, self.ticket_peoples, self.ticketInfoForPassengerForm,
self.oldPassengerStr, self.passengerTicketStrList)
csf.sendConfirmSingleForQueue()
else:
print(u"当前排队人数: {1} 当前余票还剩余:{0} 张,继续排队中".format(ticket_split, countT))
# countT = getQueueCountResult["data"]["countT"]
# if int(countT) is 0:
print(u"排队成功, 当前余票还剩余: {0}".format(ticket_split))
csf = confirmSingleForQueue(self.session, self.ifShowPassCodeTime, self.is_need_code, self.token,
self.set_type, self.ticket_peoples, self.ticketInfoForPassengerForm,
self.oldPassengerStr, self.passengerTicketStrList)
csf.sendConfirmSingleForQueue()
# else:
# print(u"当前排队人数: {1} 当前余票还剩余:{0} 张,继续排队中".format(ticket_split, countT))
else:
print(u"排队发现未知错误{0},将此列车 {1}加入小黑屋".format(getQueueCountResult, self.train_no))
wrapcache.set(key=self.train_no, value=datetime.datetime.now(),
timeout=int(_get_yaml()["ticket_black_list_time"]) * 60)
elif "messages" in getQueueCountResult and getQueueCountResult["messages"]:
print(u"排队异常,错误信息:{0}, 将此列车 {1}加入小黑屋".format(getQueueCountResult["messages"][0], self.train_no))
wrapcache.set(key=self.train_no, value=datetime.datetime.now(), timeout=int(_get_yaml()["ticket_black_list_time"]) * 60)
wrapcache.set(key=self.train_no, value=datetime.datetime.now(),
timeout=int(_get_yaml()["ticket_black_list_time"]) * 60)
else:
if "validateMessages" in getQueueCountResult and getQueueCountResult["validateMessages"]:
print(str(getQueueCountResult["validateMessages"]))
@ -101,6 +102,3 @@ class getQueueCount:
timeout=int(_get_yaml()["ticket_black_list_time"]) * 60)
else:
print(u"未知错误 {0}".format("".join(getQueueCountResult)))

@ -171,9 +171,10 @@ class query:
if self.session.is_cdn == 1:
while True:
if self.session.cdn_list:
time.sleep(0.1)
self.httpClint.cdn = self.session.cdn_list[random.randint(0, len(self.session.cdn_list) - 1)]
else:
time.sleep(0.05)
time.sleep(0.1)
if __name__ == "__main__":

Loading…
Cancel
Save