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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
def fetch(level=1, data=None, user='******', passwd=''): # Walk from the root node, where level == 1. if data is None: data = { 'url': 'http://www.mido.cn/zh/retailer_li/POS', 'brand_id': 10260, 'brandname_e': u'MIDO', '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'])) url = data['url'] try: data['html'] = cm.get_data(url) except Exception: print 'Error occured: %s' % url dump_data = { 'level': 0, 'time': cm.format_time(), 'data': { 'url': url }, 'brand_id': data['brand_id'] } cm.dump(dump_data) return [] store_list = fetch_countries(data) db.disconnect_db()
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
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
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://us.levi.com/storeLocServ', 'brand_id': 10215, 'brandname_e': u"Levi's", 'brandname_c': u"Levi's"} 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(fetch_hk(data)) results = fetch_jp(data) db.disconnect_db() cm.dump('Done!', log_name) return results
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
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
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
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
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 = {'host': 'http://www.audemarspiguet.com', 'url': 'http://www.audemarspiguet.com/en/where-to-buy', 'brand_id': 10022, 'brandname_e': u'Audemars Piguet', '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