Advertisement
Sandbird

Untitled

Jul 23rd, 2021 (edited)
1,255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.14 KB | None | 0 0
  1. #coding=utf-8                                                                                                                                                                              
  2. import time
  3. from selenium import webdriver
  4. from selenium.webdriver.chrome.options import Options
  5.  
  6. user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.50 Safari/537.36'
  7.  
  8. options = webdriver.ChromeOptions()
  9. #options.headless = True
  10. options.add_argument("--headless")
  11. options.add_argument('no-sandbox')
  12. options.add_argument('user-agent={user_agent}')
  13. driver = webdriver.Chrome(executable_path='C:/Users/xxxxx/AppData/Local/Python/chromedriver_win32/chromedriver.exe', chrome_options=options, service_args=['--verbose'])
  14.  
  15.  
  16. URL = 'http://example.com/graph.html'
  17.  
  18. driver.get(URL)
  19. S = lambda X: driver.execute_script('return document.body.parentNode.scroll'+X)
  20. driver.set_window_size(S('Width'),S('Height')) # May need manual adjustment                                                                                                                
  21. driver.find_element_by_id('tttt').screenshot('1.png')
  22.  
  23. driver.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement