hhh_phantom.py 722 B

123456789101112131415161718192021222324
  1. from selenium import webdriver
  2. import time
  3. import random
  4. lst=['13781','3649','2116']
  5. for i in range(9999):
  6. options = webdriver.ChromeOptions()
  7. options.add_argument('--headless')
  8. options.add_argument('--disable-gpu') # Last I checked this was necessary.
  9. options.add_argument('--no-sandbox')
  10. options.add_argument('--disable-dev-shm-usage')
  11. driver = webdriver.Chrome(
  12. desired_capabilities=options.to_capabilities())
  13. driver.set_window_size(1400,1000)
  14. l=random.choice(lst)
  15. driver.get("https://www.hhh.com.tw/cases/detail/"+l+"/index.php")
  16. print(driver.current_url)
  17. driver.implicitly_wait (6)
  18. time.sleep(6)
  19. driver.save_screenshot('c:/tmp/test.png')
  20. driver.quit()