Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# -*- cofing: utf-8 -*-
import sys
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import chromedriver_binary
script_name = sys.argv[0]
options = Options()
options.add_argument('--headless')
driver = webdriver.Chrome(options=options)
try:
url = sys.argv[1]
driver.get(url)
page_width = driver.execute_script('return document.body.scrollWidth')
page_height = driver.execute_script('return document.body.scrollHeight')
driver.set_window_size(page_width, page_height)
driver.save_screenshot('screenshot.png')
driver.quit()
print("SUCCESS")
except IndexError:
print('Usage: %s URL' % script_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment