|
@@ -51,6 +51,7 @@ def process_query(qs):
|
|
|
q=qs[0]
|
|
|
url=qs[1]
|
|
|
client=qs[2]
|
|
|
+ domain=qs[3]
|
|
|
global driver
|
|
|
escaped_search_term = urllib.parse.quote(q)
|
|
|
googleurl = 'https://www.google.com/search?q={}&num={}&hl={}'.format(escaped_search_term, 100, 'zh-TW')
|
|
@@ -72,7 +73,7 @@ def process_query(qs):
|
|
|
print(href)
|
|
|
print(txt)
|
|
|
print("ranking", idx)
|
|
|
- table.insert({'kw':q,'client':client,'ranking':idx,'title':txt,'url':href,'dt':datetime.datetime.now()})
|
|
|
+ table.insert({'kw':q,'client':client,'ranking':idx,'title':txt,'url':href,'dt':datetime.datetime.now(),'domain':domain})
|
|
|
webdriver.ActionChains(driver).move_to_element(elmt).perform()
|
|
|
webdriver.ActionChains(driver).move_to_element(elmt).click().perform()
|
|
|
time.sleep(5)
|
|
@@ -86,7 +87,7 @@ def run_once(q):
|
|
|
options = webdriver.ChromeOptions()
|
|
|
options.add_argument('--headless')
|
|
|
options.add_argument('--remote-debugging-port=9222')
|
|
|
- options.add_experimental_option("debuggerAddress", f"127.0.0.1:{q[2]}")
|
|
|
+ options.add_experimental_option("debuggerAddress", f"127.0.0.1:{q[3]}")
|
|
|
options.add_argument("--user-agent=" +user_agent)
|
|
|
options.add_argument("--incognito")
|
|
|
|
|
@@ -103,9 +104,9 @@ def run_once(q):
|
|
|
|
|
|
class JParams(object):
|
|
|
|
|
|
- def get(self, kw,url,client,port):
|
|
|
+ def get(self, kw,url,client,port,domain):
|
|
|
print('關鍵字',kw)
|
|
|
- run_once( (kw,url,client,port) )
|
|
|
+ run_once( (kw,url,client,port,domain) )
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|