Skip to content

Instantly share code, notes, and snippets.

@PanagiotisPtr
Created December 15, 2018 00:29
Show Gist options
  • Save PanagiotisPtr/adb770649839ad3e6ad7246e28ba47ef to your computer and use it in GitHub Desktop.
Save PanagiotisPtr/adb770649839ad3e6ad7246e28ba47ef to your computer and use it in GitHub Desktop.
Screencapture scrollable page
# This script does use selenium and the firefox webdriver to run
# make sure you setup those first.
from selenium import webdriver
import time
options = webdriver.FirefoxOptions()
options.add_argument("--headless")
driver = webdriver.Firefox(firefox_options=options)
url = input("Website: ")
filename = input("Filename: ")
sec = input("Delay: ")
sec = float(sec)
driver.get(url)
e = driver.find_element_by_css_selector("body")
height = e.size['height']
width = e.size['width']
driver.set_window_position(0, 0)
driver.set_window_size(width, height)
time.sleep(sec)
driver.save_screenshot(filename)
print("Image Saved.")
print("Height: ", height, "\tWidth: ", width)
driver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment