def query(flag, base_url, trainDate, fromStation, toStation, passengerType=PASSENGER_TYPE_ADULT): # params = { # r'leftTicketDTO.train_date': trainDate, # r'leftTicketDTO.from_station': city2code(fromStation), # r'leftTicketDTO.to_station': city2code(toStation), # r'purpose_codes': passengerType # } params = collections.OrderedDict() params['leftTicketDTO.train_date'] = trainDate params['leftTicketDTO.from_station'] = city2code(fromStation) params['leftTicketDTO.to_station'] = city2code(toStation) params['purpose_codes'] = passengerType if flag > 1: jsonRet = EasyHttp.send(queryUrls['query'], params=params) else: for suffix in ['', 'O', 'X', 'Z', 'A', 'T', 'V']: queryUrls['query']['url'] = base_url + suffix jsonRet = EasyHttp.send(queryUrls['query'], params=params) if jsonRet: break try: if jsonRet: return Query.__decode(jsonRet['data']['result'], passengerType) except Exception as e: Log.e(e) return []
def query(flag, base_url, trainDate, fromStation, toStation, passengerType=PASSENGER_TYPE_ADULT): params = collections.OrderedDict() params['leftTicketDTO.train_date'] = trainDate params['leftTicketDTO.from_station'] = city2code(fromStation) params['leftTicketDTO.to_station'] = city2code(toStation) params['purpose_codes'] = passengerType jsonRet = eHttp.send(queryUrls['query'], params=params) try: if jsonRet: return Query.__decode(jsonRet['data']['result'], passengerType) except Exception as e: Log.e(e) return []