SHARE
TWEET

211 - Screenshot A Webpage

steve-shambles-2109 Feb 16th, 2020 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. """ Code-snippet-vol_43-snip_211-Selenium special.
  2. 211 - Screenshot A Webpage
  3.  
  4. Open a webpage, take a screenshot, save img, quit browser, display img.
  5.  
  6. Requirements:
  7. -------------
  8. pip3 install selenium
  9. geckodriver.exe in python path.
  10. firefox browser
  11.  
  12. By Steve Shambles. Feb 2020
  13. stevepython.wordpress.com
  14. """
  15. from time import sleep
  16. import webbrowser
  17. from selenium import webdriver
  18.  
  19. driver = webdriver.Firefox()
  20.  
  21. driver.maximize_window()
  22. driver.get('http://www.punkfm.co.uk/')
  23. sleep(2)
  24.  
  25. driver.save_screenshot('scrn.png')
  26.  
  27. webbrowser.open('scrn.png')
  28.  
  29. driver.quit()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top