Ejemplo n.º 1
0
                break

            for i in range(stores_thispage):
                if bfinal:
                    print('跳出本頁搜尋列表')
                    break
                dic_store = {}  # 每個店家的資訊存進dic_store
                choose = False  # selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document

                results = find_tags(driver, dic_tag['stores'], logger=logger)

                if results[i].get_attribute(dic_tag['label']) != '':
                    ad = results[i].find_elements_by_class_name('ad-badge')[
                        0]  # 會有多個廣告tag,只看第一個
                    name_ori = results[i].get_attribute(dic_tag['label'])
                    name = checkName(name_ori,
                                     logger=logger)  # 若含有特殊符號,無法作為檔名儲存
                    road = find_tags(results[i],
                                     dic_tag['road'],
                                     logger=logger)[0].text
                    pricetag = results[i].find_elements_by_class_name(
                        dic_tag['price'])[0].get_attribute(
                            dic_tag['label'])  # 找到價錢tag
                    price = ''
                    if pricetag != None:
                        price = pricetag.split(' ')[-1][0]
                    saved_latest_date = ''
                    saved_latest_review = ''

                    addr = ''
                    if 'display' not in ad.get_attribute('style'):
                        print('跳過這個廣告店家:', name)
Ejemplo n.º 2
0
                print('目前頁數', page, '已超過設定頁數:', totalpage)
                bfinal = True
                break

            for i in range(count_thispage):
                if bfinal:
                    print('跳出本頁搜尋列表')
                    break
                dic_store = {} # 每個店家的資訊存進dic_store
                choose = False # selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document

                sessions = find_tags(driver, dic_tag['stores'])

                if sessions[i].get_attribute(dic_tag['label']) != '':
                    ad = sessions[i].find_elements_by_class_name('ad-badge')[0] # 會有多個廣告tag,只看第一個
                    name = checkName(sessions[i].get_attribute(dic_tag['label'])) # 若含有特殊符號,無法作為檔名儲存
                    pricetag = sessions[i].find_elements_by_class_name(dic_tag['price'])[0].get_attribute(dic_tag['label']) # 找到價錢tag
                    price = ''
                    if pricetag != None:
                        price = pricetag.split(' ')[-1][0]
                    saved_latest_date = ''
                    saved_latest_review = ''

                    addr = ''
                    if 'display' not in ad.get_attribute('style') :
                        print('跳過這個廣告店家:', name)
                        continue # 廣告,跳過

                    sessions[i].click()
                    print('=== 點擊第'+ str(i+1) + '個店家:', name, '===')
Ejemplo n.º 3
0
                print('目前頁數', page, '已超過設定頁數:', totalpage)
                bfinal = True
                break

            for i in range(stores_thispage):
                if bfinal:
                    print('跳出本頁搜尋列表')
                    break
                dic_store = {} # 每個店家的資訊存進dic_store
                choose = False # selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document

                results = find_tags(driver, dic_tag['stores'])

                if results[i].get_attribute(dic_tag['label']) != '':
                    ad = results[i].find_elements_by_class_name('ad-badge')[0] # 會有多個廣告tag,只看第一個
                    name = checkName(results[i].get_attribute(dic_tag['label'])) # 若含有特殊符號,無法作為檔名儲存
                    pricetag = results[i].find_elements_by_class_name(dic_tag['price'])[0].get_attribute(dic_tag['label']) # 找到價錢tag
                    price = ''
                    if pricetag != None:
                        price = pricetag.split(' ')[-1][0]
                    saved_latest_date = ''
                    saved_latest_review = ''

                    addr = ''
                    if 'display' not in ad.get_attribute('style') :
                        print('跳過這個廣告店家:', name)
                        continue # 廣告,跳過

                    results[i].click()
                    print('=== 點擊第'+ str(i+1) + '個店家:', name, '===')