|
@@ -17,27 +17,33 @@ for l in lines:
|
|
|
elmts=l.split(',')
|
|
|
lst.append('https://www.hhh.com.tw'+elmts[0])
|
|
|
fr.close()
|
|
|
-lst=['https://www.hhh.com.tw/cases/detail/d/13051/index.php']
|
|
|
+#lst=['https://www.hhh.com.tw/cases/detail/d/13051/index.php','https://www.hhh.com.tw/columns/detail/5878/index.php']
|
|
|
#lst=['13781','3649','2116']
|
|
|
#for i in range(9999):
|
|
|
if True:
|
|
|
options = webdriver.ChromeOptions()
|
|
|
- options.add_argument('--headless')
|
|
|
+# options.add_argument('--headless')
|
|
|
options.add_argument('--disable-gpu') # Last I checked this was necessary.
|
|
|
- options.add_argument('--incognito')
|
|
|
+# options.add_argument('--incognito')
|
|
|
options.add_argument('--no-sandbox')
|
|
|
options.add_argument('--disable-dev-shm-usage')
|
|
|
+ options.add_argument('--user-data-dir=C:\\tmp\\user')
|
|
|
+
|
|
|
driver = webdriver.Chrome(
|
|
|
desired_capabilities=options.to_capabilities())
|
|
|
driver.set_window_size(1400,1000)
|
|
|
- for i in range(3):
|
|
|
+ for i in range(6):
|
|
|
l=random.choice(lst)
|
|
|
# driver.get("https://www.hhh.com.tw/cases/detail/"+l+"/index.php")
|
|
|
- driver.get(l)
|
|
|
+# driver.get(l)
|
|
|
+ driver.execute_script('window.open("'+l+'","_blank");')
|
|
|
+
|
|
|
print(driver.current_url)
|
|
|
+ time.sleep(3)
|
|
|
driver.execute_script("window.scrollTo(0, window.scrollY + 400)")
|
|
|
+ time.sleep(3)
|
|
|
+
|
|
|
# driver.implicitly_wait (2)
|
|
|
- time.sleep(6)
|
|
|
driver.quit()
|
|
|
|
|
|
|