Exemplo n.º 1
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 国家列表
            return [{
                'func': lambda data: func(data, level + 1),
                'data': s
            } for s in fetch_countries(data)]
        if level == 1:
            # 城市列表
            return [{
                'func': lambda data: func(data, level + 1),
                'data': s
            } for s in fetch_cities(data)]
        if level == 2:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return ()

    # Walk from the root node, where level == 1.
    if data is None:
        data = {
            'store_url':
            'http://www.samsonite.co.uk/data-exchange/getDealerLocatorMapV2.aspx',
            'url': 'http://www.samsonite.co.uk/en/store-locator.htm',
            'brand_id': 10309,
            'brandname_e': u'Samsonite',
            'brandname_c': u'新秀丽',
            'search_type': 'dealer'
        }

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    # db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})

    data['search_type'] = 'repaircenter'
    results.extend(
        cm.walk_tree({
            'func': lambda data: func(data, 0),
            'data': data
        }))

    db.disconnect_db()
    cm.dump('Done!', log_name)

    return results
Exemplo n.º 2
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 国家列表
            return [{'func': lambda data: func(data, level + 1), 'data': s} for s in fetch_countries(data)]
        if level == 1:
            # 商店列表
            return [{'func': lambda data: func(data, level + 1), 'data': s} for s in fetch_store_list(data)]
        if level == 2:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return ()

    def func_cn(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 城市列表
            return [{'func': lambda data: func_cn(data, level + 1), 'data': s} for s in fetch_cities_cn(data)]
        if level == 1:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return ()

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'data_url': 'http://www.nike.com/store-locator/v2/locations',
                'country_url': 'http://www.nike.com/us/en_us/sl/find-a-store',
                'brand_id': 10277, 'brandname_e': u'Nike', 'brandname_c': u'耐克',
                'city_map': gen_city_map()}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    results.extend(cm.walk_tree({'func': lambda data: func_cn(data, 0), 'data': data}))

    db.disconnect_db()
    cm.dump('Done!', log_name)

    return results
Exemplo n.º 3
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 国家
            return [{'func': lambda data: func(data, 1), 'data': c} for c in get_countries(data)]
        elif level == 1:
            store_list = get_stores(data)
            return [{'func': None, 'data': s} for s in store_list]
        #     # 城市列表
        #     return [{'func': lambda data: func(data, 2), 'data': s} for s in get_cities(data)]
        # elif level == 2:
        #     # 商店列表
        #     return [{'func': lambda data: func(data, 3), 'data': s} for s in get_store_list(data)]
        # elif level == 3:
        #     # 商店的具体信息
        #     store = get_store_details(data)
        #     return [{'func': None, 'data': store}]
        else:
            return []

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', brand_id))
    # Walk from the root node, where level == 1.
    if data is None:
        data = {'url': url}
    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()
    return results
Exemplo n.º 4
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 国家列表
            return [{'func': lambda data: func(data, 1), 'data': s} for s in fetch_countries(data)]
        if level == 1:
            # 城市列表
            return [{'func': lambda data: func(data, 2), 'data': s} for s in fetch_cities(data)]
        if level == 2:
            # 商店详情
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'home_url': 'http://www.benetton.com/store-locator/',
                'data_url': 'http://www.benetton.com/storelocator/map_ajax.php',
                'brand_id': 10038, 'brandname_e': u'Benetton', 'brandname_c': u'贝纳通'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 5
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 国家列表
            return [{'func': lambda data: func(data, level + 1), 'data': s} for s in fetch_countries(data)]
        if level == 1:
            # 城市列表
            return [{'func': lambda data: func(data, level + 1), 'data': s} for s in fetch_cities(data)]
        if level == 2:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return ()

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'data_url': 'http://www.breguet.com/en/content/action',
                'url': 'http://www.breguet.com/en/Worldwide-retailers',
                'brand_id': 10053, 'brandname_e': u'Breguet', 'brandname_c': u'宝玑'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()
    cm.dump('Done!', log_name)

    return results
Exemplo n.º 6
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 国家列表
            return [{'func': lambda data: func(data, level + 1), 'data': s} for s in fetch_countries(data)]
        if level == 1:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'data_url': 'http://www.tods.com/en/boutiques/index/getStoresByCountry',
                'url': 'http://www.tods.com/en/boutiques/',
                'brand_id': 10354, 'brandname_e': u"Tod's", 'brandname_c': u'托德斯'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 7
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'url': 'http://cdn.lanvin.com/xml/footer/en/store-locator.xml',
                'brand_id': 10212, 'brandname_e': u'Lanvin', 'brandname_c': u'浪凡'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    gs.commit_maps(1)

    return results
Exemplo n.º 8
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {
            'url': 'http://cdn.lanvin.com/xml/footer/en/store-locator.xml',
            'brand_id': 10212,
            'brandname_e': u'Lanvin',
            'brandname_c': u'浪凡'
        }

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' %
               ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    gs.commit_maps(1)

    return results
Exemplo n.º 9
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 国家列表
            return [{'func': lambda data: func(data, level + 1), 'data': s} for s in fetch_countries(data)]
        if level == 1:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return ()

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'url': 'http://viviennetam.com/contact/store-locator',
                'brand_id': 10400, 'brandname_e': u'Vivienne Tam', 'brandname_c': u'Vivienne Tam'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()
    cm.dump('Done!', log_name)

    return results
Exemplo n.º 10
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 商店列表
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {
            'home_url': 'http://www.balenciaga.com/experience/us?yoox_storelocator_action=true&action=yoox_storelocator_get_stores',
            'brand_id': 10029, 'brandname_e': u'Balenciaga', 'brandname_c': u'巴黎世家'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 11
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 国家列表
            return [{'func': lambda data: func(data, level + 1), 'data': s} for s in fetch_countries(data)]
        if level == 1:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return ()

    # Walk from the root node, where level == 1.
    if data is None:
        data = {
            'data_url': 'http://www.c-and-a.com/uk/en/corporate/company/stores/storefinder/?no_cache=1&tx_iostorefinder_pi1%5Baction%5D=search&tx_iostorefinder_pi1%5Bcontroller%5D=store',
            'url': 'http://www.c-and-a.com/uk/en/corporate/fashion/stores/',
            'brand_id': 10059, 'brandname_e': u'C&A', 'brandname_c': u'C&A'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()
    cm.dump('Done!', log_name)

    return results
Exemplo n.º 12
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {
            'url':
            'http://www.ferragamo.com/wcsstore/FerragamoStorefrontAssetStore/flash/store',
            'brand_id': 10308,
            'brandname_e': u'Salvatore Ferragamo',
            'brandname_c': u'菲拉格慕'
        }

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' %
               ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 13
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 国家列表
            return [{'func': lambda data: func(data, level + 1), 'data': s} for s in fetch_countries(data)]
        if level == 1:
            # 国家列表
            return [{'func': lambda data: func(data, level + 1), 'data': s} for s in fetch_cities(data)]
        if level == 2:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'city_url': '/store/locationfilterpartial', 'store_url': '/store/list',
                'host': 'http://www.marcjacobs.com',
                'url': 'http://www.marcjacobs.com/store',
                'brand_id': 10239, 'brandname_e': u'Marc Jacobs', 'brandname_c': u'马克雅克布'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 14
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 国家列表
            return [{'func': lambda data: func(data, 1), 'data': c} for c in fetch_countries(data)]
        elif level == 1:
            # 城市信息
            return [{'func': lambda data: func(data, 2), 'data': c} for c in fetch_cities(data)]
        elif level == 2:
            # 商店信息
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'home_url': 'http://www.paulshark.it/en/storelocator',
                'data_url': 'http://www.paulshark.it/StoreLocator/ajaxGetCitiesByCountry',
                'store_url': 'http://www.paulshark.it/en/StoreLocator/getResultsMarkersFisso',
                'brand_id': 10298, 'brandname_e': u'Paul & Shark', 'brandname_c': u'保罗与鲨鱼'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 15
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 商店列表
            return [{'func': lambda data: func(data, level + 1), 'data': s} for s in fetch_store_list(data)]
        if level == 1:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_store_details(data)]
        else:
            return ()

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'url': 'http://www.chaumet.com/all-points-of-sale',
                'brand_id': 10076, 'brandname_e': u'Chaumet', 'brandname_c': u'尚美巴黎'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()
    cm.dump('Done!', log_name)

    return results
Exemplo n.º 16
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'url': 'http://www.isseymiyake.com/en/shops/xml/list.xml',
                'brand_id': 10175, 'brandname_e': u'ISSEY MIYAKE', 'brandname_c': u'三宅一生'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 17
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 国家
            return [{'func': lambda data: func(data, 1), 'data': c} for c in get_countries(data)]
        elif level == 1:
            # 城市列表
            return [{'func': lambda data: func(data, 2), 'data': s} for s in get_cities(data)]
        elif level == 2:
            # 商店列表
            return [{'func': lambda data: func(data, 3), 'data': s} for s in get_store_list(data)]
        elif level == 3:
            # 商店的具体信息
            store = get_store_details(data)
            return [{'func': None, 'data': store}]
        else:
            return []

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', brand_id))


    # Walk from the root node, where level == 1.
    if data is None:
        data = {'url': url}
    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 18
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 国家列表
            return [{'func': lambda data: func(data, 1), 'data': c} for c in fetch_countries(data)]
        elif level == 1:
            # 城市信息
            return [{'func': lambda data: func(data, 2), 'data': s} for s in fetch_cities(data)]
        elif level == 2:
            # 商店信息
            store_list = fetch_stores(data)
            return [{'func': None, 'data': s} for s in store_list]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'post_shops': 'http://www.paulandjoe.com/storelocator/index/shops/',
                'post_city': 'http://www.paulandjoe.com/storelocator/index/city/',
                'home_url': 'http://www.paulandjoe.com/storelocator/',
                'brand_id': 10297, 'brandname_e': u'Paul & Joe', 'brandname_c': u''}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 19
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'url': 'http://www.tommy.com.cn/storelocator/index/getmapajax',
                'brand_id': 10355, 'brandname_e': u'Tommy Hilfiger', 'brandname_c': u'汤米·希尔费格'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()
    cm.dump('Done!', log_name)

    return results
Exemplo n.º 20
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {
            'url': 'http://www.isseymiyake.com/en/shops/xml/list.xml',
            'brand_id': 10175,
            'brandname_e': u'ISSEY MIYAKE',
            'brandname_c': u'三宅一生'
        }

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' %
               ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 21
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 国家列表
            return [{'func': lambda data: func(data, level + 1), 'data': s} for s in fetch_countries(data)]
        if level == 1:
            # 城市列表
            return [{'func': lambda data: func(data, level + 1), 'data': s} for s in fetch_cities(data)]
        if level == 2:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'country_url': 'http://shop.mango.com/web/oi/servicios/tiendas/getpaises.php',
                'city_url': 'http://shop.mango.com/web/oi/servicios/tiendas/getciudades.php',
                'store_url': 'http://shop.mango.com/web/oi/servicios/tiendas/getdirecciones.php',
                'brand_id': 10235, 'brandname_e': u'Mango', 'brandname_c': u'芒果'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 22
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return ()

    # Walk from the root node, where level == 1.
    if data is None:
        data = {
            'url': 'http://experience.trussardi.com/en/pages/store-locator/',
            'brand_id': 10360,
            'brandname_e': u'Trussardi',
            'brandname_c': u'楚萨迪'
        }

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' %
               ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()
    cm.dump('Done!', log_name)

    return results
Exemplo n.º 23
0
def fetch(level=1, data=None, user="******", passwd=""):
    def func(data, level):
        """
        :param data:
        :param level: 1: 国家列表;2:城市列表;3:获得单独的门店信息
        """
        if level == 1:
            countries = get_countries(data["url"])
            return [{"func": lambda data: func(data, 2), "data": c} for c in countries]
        elif level == 2:
            cities = get_cities(data)
            return [{"func": lambda data: func(data, 3), "data": c} for c in cities]
        elif level == 3:
            store_list = get_stores(data)
            return [{"func": None, "data": s} for s in store_list]

    global db
    db = common.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u"DELETE FROM %s WHERE brand_id=%d" % ("stores", brand_id))

    # Walk from the root node, where level == 1.
    if data is None:
        data = {"url": url}
    results = common.walk_tree({"func": lambda data: func(data, level), "data": data})
    db.disconnect_db()
    return results
Exemplo n.º 24
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 洲列表
            return [{'func': lambda data: func(data, 1), 'data': s} for s in fetch_continents(data)]
        if level == 1:
            # 国家列表
            return [{'func': lambda data: func(data, 2), 'data': s} for s in fetch_countries(data)]
        if level == 2:
            # 商店列表
            return [{'func': lambda data: func(data, 3), 'data': s} for s in fetch_stores(data)]
        if level == 3:
            # 商店详情
            return [{'func': None, 'data': s} for s in fetch_store_details(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'url': 'http://www.etro.com/en_wr/storefinder/get/list/continent/',
                'brand_id': 10127, 'brandname_e': u'Etro', 'brandname_c': u'艾特罗'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 25
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 国家列表
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'url': 'http://international.tiffany.com/Locations/Default.aspx/GetAllStoreLocationsForMapping',
                'brand_id': 10350, 'brandname_e': u'Tiffany&Co', 'brandname_c': u'蒂芙尼'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 26
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 国家列表
            return [{'func': lambda data: func(data, 1), 'data': c} for c in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'url': 'http://www.ninewest.com/on/demandware.store/Sites-ninewest-Site/default/Stores-Find',
                'brand_id': 10279, 'brandname_e': u'Nine West', 'brandname_c': u'玖熙'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 27
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return ()

    # Walk from the root node, where level == 1.
    if data is None:
        data = {
            'host': 'http://m.louisvuitton.eu',
            'url':
            'http://a.louisvuitton.com/mobile/ajax/getStoreJson.jsp?storeLang=eng_E1&module=storelocator&category=index&latitudeA=89&longitudeA=-179&latitudeB=-89&longitudeB=179&doClosestSearch=false&zoomLevel=3&country=undefined&categories=',
            'brand_id': 10226,
            'brandname_e': u'Louis Vuitton',
            'brandname_c': u'路易威登'
        }

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' %
               ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()
    cm.dump('Done!', log_name)

    return results
Exemplo n.º 28
0
def fetch(level=0, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 国家列表
            return [{'func': lambda data: func(data, 1), 'data': c} for c in fetch_countries(data)]
        elif level == 1:
            # 商店列表
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'url': 'http://www.marni.cn/experience/marni/en/marni_group/shops.asp',
                'host': 'http://www.marni.cn',
                'key_term': 'A444F5AB', 'brand_id': 10241, 'brandname_e': u'Marni', 'brandname_c': u'玛尼'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 29
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return ()

    # Walk from the root node, where level == 1.
    if data is None:
        data = {
            'data_url': 'xxxxxxxxxx',
            'url': 'http://www.hamiltonwatch.com/storelocator/stores/',
            'brand_id': 10157,
            'brandname_e': u'Hamilton',
            'brandname_c': u'汉密尔顿'
        }

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    # db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()
    cm.dump('Done!', log_name)

    return results
Exemplo n.º 30
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'url': 'http://www.ferragamo.com/wcsstore/FerragamoStorefrontAssetStore/flash/store',
                'brand_id': 10308, 'brandname_e': u'Salvatore Ferragamo', 'brandname_c': u'菲拉格慕'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 31
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 商店列表
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'url': 'http://placesws.adidas-group.com/API/search',
                'brand_id': 10004, 'brandname_e': u'Adidas SLVR Label', 'brandname_c': u'阿迪达斯'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 32
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {
            'url':
            'http://www.patek.com/contents/default/en/findretailer.html',
            'brand_id': 10296,
            'brandname_e': u'Patek Philippe',
            'brandname_c': u'百达翡丽'
        }

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' %
               ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 33
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 1: 国家列表;2:城市列表;3:获得单独的门店信息
        """
        if level == 1:
            countries = get_countries(data['url'])
            return [{'func': lambda data: func(data, 2), 'data': c} for c in countries]
        elif level == 2:
            cities = get_cities(data)
            return [{'func': lambda data: func(data, 3), 'data': c} for c in cities]
        elif level == 3:
            store_list = get_stores(data)
            return [{'func': None, 'data': s} for s in store_list]

    global db
    db = common.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', brand_id))

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'url': url}
    results = common.walk_tree({'func': lambda data: func(data, level), 'data': data})
    db.disconnect_db()
    return results
Exemplo n.º 34
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {
            'url': 'http://www.iwc.com/site_media/CACHE/js/48b43df5a427.js',
            'brand_id': 10176,
            'brandname_e': u'IWC',
            'brandname_c': u'万国'
        }

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' %
               ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 35
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 国家列表
            return [{'func': lambda data: func(data, level + 1), 'data': s} for s in fetch_countries(data)]
        if level == 1:
            # 城市列表
            return [{'func': lambda data: func(data, level + 1), 'data': s} for s in fetch_cities(data)]
        if level == 2:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
            pass
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'url': 'http://www.cartier.us/find-boutique',
                'data_url': 'http://www.cartier.us/system/ajax',
                'brand_id': 10066, 'brandname_e': u'Cartier', 'brandname_c': u'卡地亚'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 36
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {
            'url': 'http://www.tommy.com.cn/storelocator/index/getmapajax',
            'brand_id': 10355,
            'brandname_e': u'Tommy Hilfiger',
            'brandname_c': u'汤米·希尔费格'
        }

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' %
               ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()
    cm.dump('Done!', log_name)

    return results
Exemplo n.º 37
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return ()

    # Walk from the root node, where level == 1.
    if data is None:
        data = {
            'url': 'http://www.ysl.com/en_US/stores',
            'brand_id': 10388,
            'brandname_e': u'YSL (Yve Saint Laurent)',
            'brandname_c': u'伊夫圣罗兰'
        }

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' %
               ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()
    cm.dump('Done!', log_name)

    return results
Exemplo n.º 38
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return ()

    # Walk from the root node, where level == 1.
    if data is None:
        data = {
            'url':
            'http://www.chloe.com/languages/en/xml/boutiques_data.xml?CacheBuster=1372490251197',
            'brand_id': 10079,
            'brandname_e': u'Chloe',
            'brandname_c': u'蔻依'
        }

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' %
               ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()
    cm.dump('Done!', log_name)

    return results
Exemplo n.º 39
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 国家列表
            return [{'func': lambda data: func(data, level + 1), 'data': s} for s in fetch_countries(data)]
        if level == 1:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'data_url': 'http://www.gucci.com/us/storelocator/stores.json',
                'url': 'http://www.gucci.com/us/storelocator',
                'brand_id': 10152, 'brandname_e': u'Gucci', 'brandname_c': u'古驰'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 40
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'url': 'http://www.patek.com/contents/default/en/findretailer.html',
                'brand_id': 10296, 'brandname_e': u'Patek Philippe', 'brandname_c': u'百达翡丽'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 41
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 国家列表
            return [{'func': lambda data: func(data, level + 1), 'data': s} for s in fetch_countries(data)]
        if level == 1:
            # 城市列表
            return [{'func': lambda data: func(data, level + 1), 'data': s} for s in fetch_cities(data)]
        if level == 2:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return ()

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'url': 'http://www.levi.com/GB/en_GB/findAStore',
                'brand_id': 10215, 'brandname_e': u"Levi's", 'brandname_c': u"Levi's",
                'city_map': gen_city_map()}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    # db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()
    cm.dump('Done!', log_name)

    return results
Exemplo n.º 42
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 城市列表
            return [{'func': lambda data: func(data, 1), 'data': s} for s in fetch_cities(data)]
        if level == 1:
            # 商店列表
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'home_url': 'http://www.canali.it/en/stores/',
                'host': 'http://www.canali.it',
                'brand_id': 10062, 'brandname_e': u'Canali', 'brandname_c': u'康纳利'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 43
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """

        :param data:
        :param level: 1: 获得众多门店列表;2:获得单独的门店信息
        """
        if level == 1:
            store_list = fetch_store_list(data['url'])
            return [{
                'func': lambda data: func(data, 2),
                'data': s
            } for s in store_list]
        elif level == 2:
            stores = fetch_store_details(data['url'], data)
            return [{'func': None, 'data': s} for s in stores]
        pass

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', brand_id))

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'url': url}
    results = cm.walk_tree({'func': lambda data: func(data, 1), 'data': data})
    db.disconnect_db()
    return results
Exemplo n.º 44
0
def fetch(db, data=None, user='******', passwd=''):
    logging.config.fileConfig('paul_joe.cfg')
    logger = logging.getLogger('firenzeLogger')
    logger.info(u'paul_joe STARTED')

    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 商店信息
            store_list = fetch_stores(db, data, logger)
            return [{'func': None, 'data': s} for s in store_list]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'post_shops': 'http://www.paulandjoe.com/storelocator/index/shops/',
                'post_city': 'http://www.paulandjoe.com/storelocator/index/city/',
                'home_url': 'http://www.paulandjoe.com/storelocator/',
                'new_store_url': 'http://www.paulandjoe.com/en/ozcms/stores/form/',
                'new_home_url': 'http://www.paulandjoe.com/en/ozcms/stores/search/',
                'brand_id': 10297, 'brandname_e': u'Paul & Joe', 'brandname_c': u''}

    db.query(str.format('DELETE FROM spider_stores.stores WHERE brand_id={0}', data['brand_id']))
    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    logging.info(u'DONE')

    return results
Exemplo n.º 45
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {
            'url': 'http://www.mulberry.com/about/store_locator.asp',
            'brand_id': 10270,
            'brandname_e': u'Mulberry',
            'brandname_c': u'迈宝瑞'
        }

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' %
               ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 46
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 国家列表
            return [{'func': lambda data: func(data, level + 1), 'data': s} for s in fetch_countries(data)]
        if level == 1:
            # 城市列表
            return [{'func': lambda data: func(data, level + 1), 'data': s} for s in fetch_cities(data)]
        if level == 2:
            # 商店
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'url': 'http://www.stellamccartney.com/experience/en/stellas-world/store-locator/',
                'data_url': 'http://www.stellamccartney.com/experience/en/wpapi/ajax-service/',
                'brand_id': 10333, 'brandname_e': u'Stella McCartney', 'brandname_c': u'斯特拉·麦卡特尼'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 47
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 商店列表
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {
            'url': 'http://placesws.adidas-group.com/API/search',
            'brand_id': 10004,
            'brandname_e': u'Adidas SLVR Label',
            'brandname_c': u'阿迪达斯'
        }

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' %
               ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results
Exemplo n.º 48
0
def fetch(level=1, data=None, user='******', passwd=''):
    def func(data, level):
        """
        :param data:
        :param level: 0:国家;1:城市;2:商店列表
        """
        if level == 0:
            # 国家列表
            return [{'func': lambda data: func(data, 1), 'data': s} for s in fetch_countries(data)]
        if level == 1:
            # 商店列表
            return [{'func': None, 'data': s} for s in fetch_stores(data)]
        else:
            return []

    # Walk from the root node, where level == 1.
    if data is None:
        data = {'home_url': 'http://www.juicycouture.com/storelocator',
                'url': 'http://www.juicycouture.com/on/demandware.store/Sites-JuicyCouture-Site/en_US/Stores-GetNearestStores',
                'brand_id': 10186, 'brandname_e': u'Juicy Couture', 'brandname_c': u'橘滋'}

    global db
    db = cm.StoresDb()
    db.connect_db(user=user, passwd=passwd)
    db.execute(u'DELETE FROM %s WHERE brand_id=%d' % ('stores', data['brand_id']))

    results = cm.walk_tree({'func': lambda data: func(data, 0), 'data': data})
    db.disconnect_db()

    return results