排队时间增加

pull/66/head
wenxianping 6 years ago
parent 8c7804dd4c
commit 9a9647665f

@ -22,7 +22,7 @@ class ticket(object):
QUEUE_JOIN_BLACK = u"排队发现未知错误{0},将此列车 {1}加入小黑屋" QUEUE_JOIN_BLACK = u"排队发现未知错误{0},将此列车 {1}加入小黑屋"
QUEUE_WARNING_MSG = u"排队异常,错误信息:{0}, 将此列车 {1}加入小黑屋" QUEUE_WARNING_MSG = u"排队异常,错误信息:{0}, 将此列车 {1}加入小黑屋"
OUT_NUM = 30 # 排队请求12306的次数 OUT_NUM = 120 # 排队请求12306的次数
WAIT_OUT_NUM = u"超出排队时间,自动放弃,正在重新刷票" WAIT_OUT_NUM = u"超出排队时间,自动放弃,正在重新刷票"
WAIT_ORDER_SUCCESS = u"恭喜您订票成功,订单号为:{0}, 请立即打开浏览器登录12306访问未完成订单在30分钟内完成支付!" WAIT_ORDER_SUCCESS = u"恭喜您订票成功,订单号为:{0}, 请立即打开浏览器登录12306访问未完成订单在30分钟内完成支付!"
WAIT_ORDER_CONTINUE = u"排队等待时间预计还剩 {0} ms" WAIT_ORDER_CONTINUE = u"排队等待时间预计还剩 {0} ms"

@ -39,6 +39,7 @@ class query:
self.arrival_time = session.arrival_time self.arrival_time = session.arrival_time
self.take_time = session.take_time self.take_time = session.take_time
@classmethod @classmethod
def station_seat(self, index): def station_seat(self, index):
""" """
@ -80,9 +81,9 @@ class query:
查询 查询
:return: :return:
""" """
t1 = threading.Thread(target=self.set_cdn, args=()) if self.session.is_cdn == 1:
t1.setDaemon(True) if self.session.cdn_list:
t1.start() self.httpClint.cdn = self.session.cdn_list[random.randint(0, len(self.session.cdn_list) - 1)]
for station_date in self.station_dates: for station_date in self.station_dates:
select_url = copy.copy(self.urls["select_url"]) select_url = copy.copy(self.urls["select_url"])
select_url["req_url"] = select_url["req_url"].format(station_date, self.from_station, self.to_station, select_url["req_url"] = select_url["req_url"].format(station_date, self.from_station, self.to_station,
@ -163,19 +164,6 @@ class query:
print u"车次配置信息有误,或者返回数据异常,请检查 {}".format(station_ticket) print u"车次配置信息有误,或者返回数据异常,请检查 {}".format(station_ticket)
return {"code": ticket.FAIL_CODE, "status": False} return {"code": ticket.FAIL_CODE, "status": False}
def set_cdn(self):
"""
设置cdn
:return:
"""
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.1)
if __name__ == "__main__": if __name__ == "__main__":
q = query() q = query()

Loading…
Cancel
Save