|
@@ -22,7 +22,7 @@ path_z = 'C:/ChromeDriver' #pls adjust
|
|
|
def restart_browser():
|
|
|
options = webdriver.ChromeOptions()
|
|
|
#options.add_argument("user-agent=%s" % rua())
|
|
|
- options.add_argument('--headless')
|
|
|
+ #options.add_argument('--headless')
|
|
|
options.add_argument('--incognito')
|
|
|
options.add_argument('--no-sandbox')
|
|
|
driver=webdriver.Chrome(options=options)
|
|
@@ -61,7 +61,8 @@ def process_one(term, tgt, n, sr, se):
|
|
|
|
|
|
for elmt in elmts:
|
|
|
try:
|
|
|
- href=elmt.find_element(By.TAG_NAME,"a").get_attribute('href')
|
|
|
+ h1=elmt.find_element(By.TAG_NAME,"a")
|
|
|
+ href=h1.get_attribute('href')
|
|
|
datadict['搜尋詞'].append(term)
|
|
|
datadict['結果標題'].append(elmt.text)
|
|
|
datadict['結果網址'].append(href)
|
|
@@ -72,7 +73,7 @@ def process_one(term, tgt, n, sr, se):
|
|
|
|
|
|
if (n==1 or n==2) and href in tgt:
|
|
|
found=1
|
|
|
- clickelmt = elmt
|
|
|
+ clickelmt = h1
|
|
|
resultrank = str(cnt)
|
|
|
resultlink = href
|
|
|
resultttl = elmt.text
|