當前位置: 首頁>>代碼示例>>Python>>正文


Python stations.get方法代碼示例

本文整理匯總了Python中stations.stations.get方法的典型用法代碼示例。如果您正苦於以下問題:Python stations.get方法的具體用法?Python stations.get怎麽用?Python stations.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在stations.stations的用法示例。


在下文中一共展示了stations.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: command

# 需要導入模塊: from stations import stations [as 別名]
# 或者: from stations.stations import get [as 別名]
def command():

    arguments = docopt(__doc__)

    #print(arguments)

    from_sta = stations.get(arguments['<from>'])

    to_sta = stations.get(arguments['<to>'])

    date = arguments['<date>']

    url = 'https://kyfw.12306.cn/otn/leftTicket/query?leftTicketDTO.train_date={}&leftTicketDTO.from_station={}&leftTicketDTO.to_station={}&purpose_codes=ADULT'.format(date, from_sta, to_sta)

    resp = requests.get(url, verify=False)

    #print(resp.json())

    options = ''.join([
        key for key, value in arguments.items() if value is True
    ])

    available_trains = resp.json()['data']

    TrainsResult(available_trains, options).pretty_print() 
開發者ID:fst034356,項目名稱:crawler,代碼行數:27,代碼來源:tickets.py

示例2: cli

# 需要導入模塊: from stations import stations [as 別名]
# 或者: from stations.stations import get [as 別名]
def cli():
    """Command-line interface"""
    arguments = docopt(__doc__)
    from_station = stations.get(arguments['<from>'])
    to_station = stations.get(arguments['<to>'])
    date = arguments['<date>']
    url = ('https://kyfw.12306.cn/otn/leftTicket/query?'
           'leftTicketDTO.train_date={}&'
           'leftTicketDTO.from_station={}&leftTicketDTO.to_station={}&purpose_codes=ADULT').format(
        date, from_station, to_station
    )
    options = ''.join([
        key for key, value in arguments.items() if value is True
    ])

    r = requests.get(url, verify=False)
    res = r.json()
    if 'data' in res.keys():
        available_trains = res['data']
        TrainsCollection(available_trains, options).pretty_print()
    else:
        print('????') 
開發者ID:sheldon9527,項目名稱:pythonSpider,代碼行數:24,代碼來源:tickets.py

示例3: query_by_command

# 需要導入模塊: from stations import stations [as 別名]
# 或者: from stations.stations import get [as 別名]
def query_by_command(self):
        """command-line interface""" 
        arguments = docopt(__doc__)
        from stations import stations
        from_station = stations.get(arguments['<from>'])
        to_station = stations.get(arguments['<to>'])
        train_type = []
        all_train_type = ['-d', '-g', '-t', '-k', '-z']
        for key in all_train_type:
            if arguments[key]:
                train_type.append(key[1:].upper())
        if len(train_type) == 0:
            train_type = [x[1:].upper() for x in all_train_type]
            
        date = arguments['<date>']
        # ??URL
        url = 'https://kyfw.12306.cn/otn/lcxxcx/query?purpose_codes=ADULT&queryDate={}&from_station={}&to_station={}'.format(date,from_station, to_station)
        import requests
        requests.packages.urllib3.disable_warnings()
        r = requests.get(url, verify = False)
        rows = r.json()['data']['datas']
        
        from ticketSearch import TrainCollection
        t = TrainCollection(rows, train_type)
        t.print_pretty() 
開發者ID:jesson20121020,項目名稱:myRobot,代碼行數:27,代碼來源:tickets.py

示例4: search

# 需要導入模塊: from stations import stations [as 別名]
# 或者: from stations.stations import get [as 別名]
def search():
    arguments = docopt(__doc__)
    from_station = stations.get(arguments['<from>'])
    to_station = stations.get(arguments['<to>'])
    date = arguments['<date>']

    # ??URL
    url = 'https://kyfw.12306.cn/otn/leftTicket/queryA?leftTicketDTO.train_date={}&leftTicketDTO.from_station={}&leftTicketDTO.to_station={}&purpose_codes=ADULT'.format(
        date, from_station, to_station
    )

    options = ''.join([key for key, value in arguments.items() if value is True])

    requests.packages.urllib3.disable_warnings()

    r = requests.get(url, verify=False)
    available_trains = r.json()['data']
    TrainsCollection(available_trains, options).pretty_print() 
開發者ID:Elfsong,項目名稱:WintersWrath,代碼行數:20,代碼來源:ticket.py

示例5: cli

# 需要導入模塊: from stations import stations [as 別名]
# 或者: from stations.stations import get [as 別名]
def cli():
    """command-line interface"""
    arguments = docopt(__doc__)
    from_station = stations.get(arguments['<from>'])
    to_station = stations.get(arguments['<to>'])
    date = arguments['<date>']

    url = 'https://kyfw.12306.cn/otn/leftTicket/query?leftTicketDTO.train_date={}&leftTicketDTO.from_station={}&leftTicketDTO.to_station={}&purpose_codes=ADULT'.format(
        date, from_station, to_station)

    r = requests.get(url, verify=False)
    available_trains = r.json()['data']['result']
    available_place = r.json()['data']['map']
    options = ''.join([
        key for key, value in arguments.items() if value is True
    ])
    TrainsCollection(available_trains,available_place, options).pretty_print() 
開發者ID:lexyhp,項目名稱:12306,代碼行數:19,代碼來源:tickets.py

示例6: cli

# 需要導入模塊: from stations import stations [as 別名]
# 或者: from stations.stations import get [as 別名]
def cli():
    """command-line interface"""
    arguments = docopt(__doc__)
    from_station = stations.get(arguments['<from>'])
    to_station = stations.get(arguments['<to>'])
    global date
    date = arguments['<date>']
    # ??URL
    url = 'https://kyfw.12306.cn/otn/lcxxcx/query?purpose_codes=ADULT&queryDate={}&from_station={}&to_station={}'.format(
        date, from_station, to_station
    )
    #print(url)
    r = requests.get(url, verify=False)
    rows = r.json()['data']['datas']
    #print(r.json())
    trains = TrainCollection(rows)
    trains.pretty_print() 
開發者ID:YeXiaoRain,項目名稱:BoringCode,代碼行數:19,代碼來源:tickets.py

示例7: cli

# 需要導入模塊: from stations import stations [as 別名]
# 或者: from stations.stations import get [as 別名]
def cli():
    """command-line interface"""
    arguments = docopt(__doc__)
    from_station = stations.get(arguments['<from>'])
    to_station = stations.get(arguments['<to>'])
    date = arguments['<date>']	
    # URL
    url = 'https://kyfw.12306.cn/otn/lcxxcx/query?purpose_codes=ADULT&queryDate={}&from_station={}&to_station={}'.format(
        date, from_station, to_station
    )
    requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
    r = requests.get(url,verify = False)
    print(r)
    rows = r.json()['data']['datas']
    trains = TrainCollection(rows)
    trains.pretty_print() 
開發者ID:dzqoo,項目名稱:littleProject,代碼行數:18,代碼來源:tickets.py

示例8: _get_duration

# 需要導入模塊: from stations import stations [as 別名]
# 或者: from stations.stations import get [as 別名]
def _get_duration(self, raw_train):

        duration = raw_train.get('lishi').replace(':', '??') + '?'

        if duration.startswith('00'):
            return duration[4:]

        if duration.startswith('0'):
            return duration[1:]

        return duration 
開發者ID:fst034356,項目名稱:crawler,代碼行數:13,代碼來源:tickets.py

示例9: _get_duration

# 需要導入模塊: from stations import stations [as 別名]
# 或者: from stations.stations import get [as 別名]
def _get_duration(self, raw_train):
        duration = raw_train.get('lishi').replace(':', '??') + '?'
        if duration.startswith('00'):
            return duration[4:]
        if duration.startswith('0'):
            return duration[1:]
        return duration 
開發者ID:sheldon9527,項目名稱:pythonSpider,代碼行數:9,代碼來源:tickets.py

示例10: _get_duration

# 需要導入模塊: from stations import stations [as 別名]
# 或者: from stations.stations import get [as 別名]
def _get_duration(self, raw_train):
        duration = raw_train.get('lishi').replace(':','??')+'?'
        if duration.startswith('00'):
            return duration[4:]
        if duration.startswith('0'):
            return duration[1:]
        return duration 
開發者ID:single-pedestrian,項目名稱:Python-searchStations,代碼行數:9,代碼來源:tickets.py

示例11: cli

# 需要導入模塊: from stations import stations [as 別名]
# 或者: from stations.stations import get [as 別名]
def cli():
    arguments = docopt(__doc__)
    from_station = stations.get(arguments['<from>'])
    to_station = stations.get(arguments['<to>'])
    date = arguments['<date>']
    url = 'https://kyfw.12306.cn/otn/leftTicket/query?leftTicketDTO.train_date={}&leftTicketDTO.from_station={}&leftTicketDTO.to_station={}&purpose_codes=ADULT'.format(date,from_station,to_station)
    options = ''.join([key for key,value in arguments.items() if value is True])
    r = requests.get(url,verify=False)
    available_trains = r.json()['data']
    TrainsCollection(available_trains,options).pretty_print() 
開發者ID:single-pedestrian,項目名稱:Python-searchStations,代碼行數:12,代碼來源:tickets.py

示例12: _get_duration

# 需要導入模塊: from stations import stations [as 別名]
# 或者: from stations.stations import get [as 別名]
def _get_duration(self, raw_train):
        duration = raw_train['queryLeftNewDTO'].get('lishi').replace(':', '??') + '?'
        if duration.startswith('00'):
            return duration[4:]
        if duration.startswith('0'):
            return duration[1:]
        return duration 
開發者ID:Jimzjy,項目名稱:tickets,代碼行數:9,代碼來源:tickets.py

示例13: cli

# 需要導入模塊: from stations import stations [as 別名]
# 或者: from stations.stations import get [as 別名]
def cli():
    arguments = docopt(__doc__)
    from_station = stations.get(arguments['<from>'])
    to_station = stations.get(arguments['<to>'])
    date = arguments['<date>']
    url = 'https://kyfw.12306.cn/otn/leftTicket/queryZ?leftTicketDTO.train_date={}&leftTicketDTO.from_station={}&leftTicketDTO.to_station={}&purpose_codes=ADULT'.format(
        date, from_station, to_station)
    options = ''.join([
                          key for key, value in arguments.items() if value is True
                          ])
    r = requests.get(url, verify=False)
    available_trains = r.json()['data']
    TrainsCollection(available_trains, options).pretty_print() 
開發者ID:Jimzjy,項目名稱:tickets,代碼行數:15,代碼來源:tickets.py

示例14: colored

# 需要導入模塊: from stations import stations [as 別名]
# 或者: from stations.stations import get [as 別名]
def colored(color, text):
    table = {
        'red': '\033[91m',
        'green': '\033[92m',
        # no color
        'nc': '\033[0m'
    }
    cv = table.get(color)
    nc = table.get('nc')
    return ''.join([cv, text, nc]) 
開發者ID:YeXiaoRain,項目名稱:BoringCode,代碼行數:12,代碼來源:tickets.py

示例15: _get_duration

# 需要導入模塊: from stations import stations [as 別名]
# 或者: from stations.stations import get [as 別名]
def _get_duration(self, row):
        """
        ????????
        """
        duration = row.get('lishi').replace(':', 'h') + 'm'
        if duration.startswith('00'):
            return duration[4:]
        if duration.startswith('0'):
            return duration[1:]
        return duration 
開發者ID:YeXiaoRain,項目名稱:BoringCode,代碼行數:12,代碼來源:tickets.py


注:本文中的stations.stations.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。