# -*- coding: utf-8 -*- DB_NAME = 'google_poi' SHOP_LIST_TABLE = 'shop_list3' SHOP_LIST_TABLE_COL = ['name', 'fid', 'city', 'area', 'rating', 'user_ratings_total', 'category', 'price_level', 'addr', 'tel', 'services', 'products', 'choices', 'facilities', 'groups', 'plans', 'payments', 'safeties', 'specials', 'barrierlevels', 'items' , 'open_now', 'periods', 'weekday_text','reviews', 'shop_photo','menu_photo', 'google_url', 'item_url', 'keyword', 'crawler_date'] # SHOP_LIST_TABLE_COL = ['unique_id', 'name', 'lon', 'lat', 'city', 'area', # 'rating', 'user_ratings_total', 'category', 'price_level', # 'addr', 'tel', 'services', 'products', 'choices', # 'facilities', 'groups', 'plans', 'payments', 'safeties', # 'specials', 'barrierlevels', 'items' , # 'open_now', 'periods', 'weekday_text','reviews', # 'shop_photo','menu_photo', # 'google_url', 'item_url', 'keyword', 'crawler_date'] element_list = { 'category': ['button', {'jsaction':'pane.rating.category'}], 'rating': ['ol', {}, 'aria-label'], 'user_ratings_total': ['span', {'jsaction':'pane.rating.moreReviews'}], 'price_level':['span', {'jsan':'0.aria-label'}] } intro_list = { '服務選項': ['services','service'], '產品/服務': ['products','product'], '用餐選擇': ['choices','choice'], '設施': ['facilities','facility'], '客層族群':['groups','group'], '規劃':['plans','plan'], '付款方式':['payments','payment'], '健康與安全':['safeties','safety'], '特色':['specials','special'], '無障礙程度':['barrierlevels','barrierlevel'], '詳細資料':['items','item'] } week_list = { '星期日': 0, '星期一': 1, '星期二': 2, '星期三': 3, '星期四': 4, '星期五': 5, '星期六': 6, } def blank_check(value): while value.startswith(' '): value = value[1:] while value.endswith(' '): value = value[:-1] return value def value_check(key, value): value = blank_check(value) if key == 'rating': value = float(value.replace(' 星級','')) elif key == 'user_ratings_total': value = int(value.replace(' 則評論','').replace(',','')) elif key == 'price_level': value = len(['$' for i in value if i == '$']) if value == 0: value = '' else: value = int(value) return value