Created
February 18, 2022 09:24
-
-
Save whexy/f513a37eaa9059c330a21c738e4228b3 to your computer and use it in GitHub Desktop.
Get snapshot of webpage use selenium and headless chrome
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.chrome.options import Options | |
from selenium.webdriver.chrome.service import Service | |
# Chrome Service with driver | |
CHROMEDRIVER_PATH = '/usr/bin/chromedriver' | |
service = Service(CHROMEDRIVER_PATH) | |
# Chrome Options with headless | |
options = Options() | |
options.add_argument('--headless') | |
options.add_argument('--disable-gpu') | |
# Visit Webpage | |
driver = webdriver.Chrome(service=service, options=options) | |
driver.get("https://www.whexy.com") | |
# Get Screenshot | |
driver.get_screenshot_as_file("screenshot.png") | |
driver.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Successfully use this script to grab snapshots on my Raspberry pie. The trick is to disable GPU. 😂