jared 3 months ago
parent
commit
a09e9fd7e8
1 changed files with 19 additions and 16 deletions
  1. 19 16
      deployment/selwire_click.py

+ 19 - 16
deployment/selwire_click.py

@@ -111,7 +111,8 @@ def selenium_jared_click():
         kw=c['kw']
         plan=c['plan']
         prefix=c['prefix']
-        domain=eval(c['domain'])[0]
+#        domain=eval(c['domain'])[0]
+        domains=eval(c['domain'])
         positive=eval(c['positive'])
         break
     #kw='真理大學教堂'
@@ -147,21 +148,23 @@ def selenium_jared_click():
         txt=elmt.text
     #    print(txt)
     #    print(href)
-        if domain in href:
-            purchase_event.set_event_param(name="query", value=kw)
-            event_list = [purchase_event]
-            gtag_tracker.send(events=event_list)
-
-            webdriver.ActionChains(driver).move_to_element(elmt).perform()
-            webdriver.ActionChains(driver).move_to_element(elmt).click().perform()
-            print(domain)
-            print(href)
-            print('ranking'+str(cnt))
-            table.insert({'ranking':cnt,'kw':kw,'results':numresults,'url':href,'title':txt})
-
-            driver.quit()
-            return txt
-            break
+#        if domain in href:
+        for domain in domains:
+           if domain in href:
+                purchase_event.set_event_param(name="query", value=kw)
+                event_list = [purchase_event]
+                gtag_tracker.send(events=event_list)
+
+                webdriver.ActionChains(driver).move_to_element(elmt).perform()
+                webdriver.ActionChains(driver).move_to_element(elmt).click().perform()
+                print(domain)
+                print(href)
+                print('ranking'+str(cnt))
+                table.insert({'ranking':cnt,'kw':kw,'results':numresults,'url':href,'title':txt})
+
+                driver.quit()
+                return txt
+                break
         cnt+=1
     table.insert({'ranking':-1,'kw':kw,'results':numresults,'url':None,'title':'未收錄'})