Your Name 3 年之前
父節點
當前提交
ab6c1d5673
共有 1 個文件被更改,包括 19 次插入2 次删除
  1. 19 2
      hhh/SEO/hhh_phantom.py

+ 19 - 2
hhh/SEO/hhh_phantom.py

@@ -1,8 +1,24 @@
 from selenium import webdriver
 import time
 import random
+import codecs
 
-lst=['13781','3649','2116']
+
+
+fpath=__file__
+fpath=fpath.replace('hhh_phantom.py','urls.csv')
+
+print(fpath)
+
+lst=[]
+fr=codecs.open(fpath,'r','utf-8')
+lines=fr.readlines()
+for l in lines:
+    elmts=l.split(',')
+    lst.append('https://www.hhh.com.tw'+elmts[0])
+fr.close()
+
+#lst=['13781','3649','2116']
 for i in range(9999):
     options = webdriver.ChromeOptions()
     options.add_argument('--headless')
@@ -14,7 +30,8 @@ for i in range(9999):
     desired_capabilities=options.to_capabilities())
     driver.set_window_size(1400,1000)
     l=random.choice(lst)
-    driver.get("https://www.hhh.com.tw/cases/detail/"+l+"/index.php")
+#    driver.get("https://www.hhh.com.tw/cases/detail/"+l+"/index.php")
+    driver.get(l)
     print(driver.current_url)
     driver.implicitly_wait (6)
     time.sleep(6)