예제 #1
0
 def querySpec(flag,
               base_url,
               trainDate,
               fromStation,
               toStation,
               passengerType=PASSENGER_TYPE_ADULT,
               trainsNo=[],
               seatTypes=[SEAT_TYPE[key] for key in SEAT_TYPE],
               PASSENGERS_ID=[],
               POLICY_BILL=1):
     for ticket in Query.query(flag, base_url, trainDate, fromStation,
                               toStation, passengerType):
         # filter trainNo
         if not TrainUtils.filterTrain(ticket, trainsNo):
             continue
         # filter seat
         for seatTypeName, seatTypeProperty in TrainUtils.seatWhich(
                 seatTypes, ticket):
             if seatTypeProperty and seatTypeProperty != '无':
                 Log.v('%s %s: %s' %
                       (ticket.trainNo, seatTypeName, seatTypeProperty))
                 try:
                     remind_num = int(seatTypeProperty)
                 except Exception as e:
                     remind_num = 100
                 if POLICY_BILL == POLICY_BILL_ALL and len(
                         PASSENGERS_ID) > remind_num:
                     break
                 ticket.seatType = SEAT_TYPE[seatTypeName]
                 ticket.remindNum = remind_num
                 yield ticket
     return []
예제 #2
0
 def querySpec(flag,
               base_url,
               trainDate,
               fromStation,
               toStation,
               passengerType=PASSENGER_TYPE_ADULT,
               trainsNo=[],
               seatTypes=[SEAT_TYPE[key] for key in SEAT_TYPE],
               PASSENGERS_ID=[],
               leave_period=[],
               POLICY_BILL=1):
     for custom_date in trainDate:
         for ticket in Query.query(flag, base_url, custom_date, fromStation,
                                   toStation, passengerType):
             if '售' in ticket.mark:
                 continue
             # filter trainNo
             if not TrainUtils.filterTrain(ticket, trainsNo):
                 continue
             # filter leave time
             try:
                 if leave_period and (ticket.leaveTime < leave_period[0] or
                                      ticket.leaveTime > leave_period[1]):
                     continue
             except Exception as e:
                 pass
             # filter seat
             for seatTypeName, seatTypeProperty in TrainUtils.seatWhich(
                     seatTypes, ticket):
                 if seatTypeProperty and seatTypeProperty != '无':
                     Log.v('%s %s %s: %s' %
                           (custom_date, ticket.trainNo, seatTypeName,
                            seatTypeProperty))
                     try:
                         remind_num = int(seatTypeProperty)
                     except Exception as e:
                         remind_num = 100
                     if POLICY_BILL == POLICY_BILL_ALL and len(
                             PASSENGERS_ID) > remind_num:
                         break
                     ticket.seatType = SEAT_TYPE[seatTypeName]
                     ticket.remindNum = remind_num
                     ticket.custom_date = custom_date
                     yield ticket
     return []
예제 #3
0
 def querySpec(trainDate,
               fromStation,
               toStation,
               passengerType=PASSENGER_TYPE_ADULT,
               trainsNo=[],
               seatTypes=[SEAT_TYPE[key] for key in SEAT_TYPE]):
     for ticket in Query.query(trainDate, fromStation, toStation,
                               passengerType):
         # filter trainNo
         if not TrainUtils.filterTrain(ticket, trainsNo):
             continue
         # filter seat
         for seatTypeName, seatTypeProperty in TrainUtils.seatWhich(
                 seatTypes, ticket):
             if seatTypeProperty and seatTypeProperty != '无':
                 Log.v('%s: %s' % (seatTypeName, seatTypeProperty))
                 ticket.seatType = SEAT_TYPE[seatTypeName]
                 yield ticket
     return []
예제 #4
0
                  datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
            for ticketDetails in Query.querySpec(count, base_query_url,
                                                 trainDate, fromStation,
                                                 toStation, passengerType,
                                                 trainsNo, seatTypes,
                                                 PASSENGERS_ID, POLICY_BILL):
                if ticketDetails:
                    return ticketDetails
            time.sleep(timeInterval)


if __name__ == "__main__":
    for tecket in Query.query(1, queryUrls['query']['url'], '2019-07-31', '福州',
                              '长汀', 'ADULT'):
        print(tecket)
        if not TrainUtils.filterTrain(tecket, ['D6575']):
            continue
        for seatTypeName, seatTypeProperty in TrainUtils.seatWhich(['O'],
                                                                   tecket):
            if seatTypeProperty and seatTypeProperty != '无':
                Log.v('%s %s: %s' %
                      (tecket.trainNo, seatTypeName, seatTypeProperty))
                try:
                    remind_num = int(seatTypeProperty)
                except Exception as e:
                    remind_num = 100
                tecket.seatType = SEAT_TYPE[seatTypeName]
                tecket.remindNum = remind_num
            print('tttt', tecket)
    # Query.outputPretty('2019-07-31', '福州', '长汀')