当前位置: 首页>>代码示例>>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;未经允许,请勿转载。