1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- from selenium import webdriver
- import time
- import random
- import codecs
- 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()
- if True:
- options = webdriver.ChromeOptions()
- options.add_argument('--disable-gpu')
- 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(10):
- l=random.choice(lst)
-
- driver.execute_script('window.open("'+l+'","_blank");')
- print(driver.current_url)
- time.sleep(4)
- driver.execute_script("window.scrollTo(0, window.scrollY + 400)")
- time.sleep(2)
- time.sleep(5)
- driver.quit()
|