hhh_phantom2.py 701 B

12345678910111213141516171819202122232425262728293031323334
  1. from selenium import webdriver
  2. import time
  3. import random
  4. import codecs
  5. fpath=__file__
  6. fpath=fpath.replace('hhh_phantom2.py','urls.csv')
  7. print(fpath)
  8. lst=[]
  9. fr=codecs.open(fpath,'r','utf-8')
  10. lines=fr.readlines()
  11. for l in lines:
  12. elmts=l.split(',')
  13. lst.append('https://www.hhh.com.tw'+elmts[0])
  14. fr.close()
  15. #lst=['13781','3649','2116']
  16. for i in range(9999):
  17. driver = webdriver.PhantomJS()
  18. driver.set_window_size(1120, 550)
  19. l=random.choice(lst)
  20. # driver.get("https://www.hhh.com.tw/cases/detail/"+l+"/index.php")
  21. driver.get(l)
  22. print(driver.current_url)
  23. # driver.implicitly_wait (3)
  24. time.sleep(4)
  25. driver.save_screenshot('c:/tmp/test.png')
  26. driver.quit()