12345678910111213141516171819202122232425262728293031323334 |
- from selenium import webdriver
- import time
- import random
- import codecs
- fpath=__file__
- fpath=fpath.replace('hhh_phantom2.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):
- driver = webdriver.PhantomJS()
- driver.set_window_size(1120, 550)
- l=random.choice(lst)
- # driver.get("https://www.hhh.com.tw/cases/detail/"+l+"/index.php")
- driver.get(l)
- print(driver.current_url)
- # driver.implicitly_wait (3)
- time.sleep(4)
- driver.save_screenshot('c:/tmp/test.png')
- driver.quit()
|