示例#1
0
def _make_raw_data_fetchers():

    materials = (
        ('http://117.56.56.194/Asp/start21.aspx'              , 'utf-8', 'Glid'), # raw data of route
        ('http://117.56.56.194/Asp/GetTimeByRouteStop4.aspx'  , 'utf-8', 'GSName'), # raw data of stop
        ('http://117.56.56.194/WordPlan/WordBus.aspx?Lang=cht', 'utf-8'), # names of route
        ('http://117.56.56.194/WordPlan/cht/WordBus_PATH.js'  , 'utf-16') # names of stop
    )
    make_partial_urlfetch = ( lambda url, encoding, *keys: (
                lambda *values:
                    urlread(
                        url,
                        dict(zip(keys, values)) if keys else None,
                        encoding=encoding
                    )
            ))
    return (make_partial_urlfetch(*material) for material in materials)
示例#2
0
def _raw_route(route_name):
    '''
    Argument  : unicode route_name
    Dependence: urlfetch
    Return    : [data, ...]'''
    return RE_ROUTE_TABLE_TD.findall(urlread(URL_NTC_EBUS_ROUTE % _menu()[route_name], encoding='big5'))
示例#3
0
def _raw_menu():
    '''
    Dependence: urlfetch
    Return    : ([route_name, ...], [route_code, ...])'''
    source = urlread(URL_NTC_EBUS_MENU, encoding='big-5')
    return (RE_MENU_ROUTE_NAME.findall(source), RE_MENU_ROUTE_CODE.findall(source))