From 2d85ef1994d7f661dd0997e9f185ffa900c69f98 Mon Sep 17 00:00:00 2001 From: wenxianping <931128603@qq.com> Date: Wed, 19 Sep 2018 17:20:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BD=99=E7=A5=A8=E5=B0=8F?= =?UTF-8?q?=E4=BA=8E=E4=B9=98=E5=AE=A2=E4=BA=BA=E6=95=B0=EF=BC=8C=E5=88=99?= =?UTF-8?q?=E4=B8=8D=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- init/select_ticket_info.py | 3 ++- inter/CheckOrderInfo.py | 3 ++- inter/Query.py | 8 ++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/init/select_ticket_info.py b/init/select_ticket_info.py index 3226373..24a7ab7 100755 --- a/init/select_ticket_info.py +++ b/init/select_ticket_info.py @@ -183,7 +183,8 @@ class select: to_station_h=self.to_station, _station_seat=self._station_seat, station_trains=self.station_trains, - station_dates=self.station_dates, ) + station_dates=self.station_dates, + ticke_peoples_num=len(from_station),) queryResult = q.sendQuery() # 查询接口 if queryResult.get("status", False): diff --git a/inter/CheckOrderInfo.py b/inter/CheckOrderInfo.py index 76ea92c..867ee2f 100644 --- a/inter/CheckOrderInfo.py +++ b/inter/CheckOrderInfo.py @@ -45,7 +45,8 @@ class checkOrderInfo: CheckOrderInfoUrls = self.session.urls["checkOrderInfoUrl"] data = self.data_par() checkOrderInfoRep = self.session.httpClint.send(CheckOrderInfoUrls, data) - if 'data' in checkOrderInfoRep: + data = checkOrderInfoRep.get("data", {}) + if data and data.get("submitStatus", False): print (u'车票提交通过,正在尝试排队') ifShowPassCodeTime = int(checkOrderInfoRep["data"]["ifShowPassCodeTime"]) / float(1000) if "ifShowPassCode" in checkOrderInfoRep["data"] and checkOrderInfoRep["data"]["ifShowPassCode"] == "Y": diff --git a/inter/Query.py b/inter/Query.py index 013b012..a455bb5 100644 --- a/inter/Query.py +++ b/inter/Query.py @@ -11,7 +11,7 @@ class query: """ def __init__(self, session, from_station, to_station, from_station_h, to_station_h, _station_seat, station_trains, - station_dates=None, ): + ticke_peoples_num, station_dates=None,): self.session = session self.from_station = from_station self.to_station = to_station @@ -21,6 +21,7 @@ class query: self._station_seat = _station_seat if isinstance(_station_seat, list) else list(_station_seat) self.station_dates = station_dates if isinstance(station_dates, list) else list(station_dates) self.ticket_black_list = dict() + self.ticke_peoples_num = ticke_peoples_num def station_seat(self, index): """ @@ -74,7 +75,10 @@ class query: ticket_info[self.station_seat(self._station_seat[j].encode("utf8"))])) if wrapcache.get(train_no): print(ticket.QUERY_IN_BLACK_LIST.format(train_no)) - break + continue + if self.ticke_peoples_num < int(ticket_info[self.station_seat(self._station_seat[j].encode("utf8"))]): + # 小于乘车人数则无视此次乘车机会, 以后可以扩展为有票优先提交 + continue else: print (ticket.QUERY_C) return {