Skip to content

Instantly share code, notes, and snippets.

@rwincey
Created February 26, 2019 15:31
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rwincey/b693cc0765378d50157052d8e4d4d1c3 to your computer and use it in GitHub Desktop.
Save rwincey/b693cc0765378d50157052d8e4d4d1c3 to your computer and use it in GitHub Desktop.
Website screenshot
# Author: b0yd @rwincey
# Website: securifera.com
#
# Setup:
# -------------------------------------------------
# pip install selenium
# wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
# google-chrome-stable --version
# Vist http://chromedriver.chromium.org/downloads to identity the right version
# wget https://chromedriver.storage.googleapis.com/72.0.3626.69/chromedriver_linux64.zip
#
# Usage:
# -------------------------------------------------
# python http_screenshot.py -u https://www.google.com -f goog.png
import argparse
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
parser = argparse.ArgumentParser(description='Screenshot a website.')
parser.add_argument('-u', dest='url', help='Website URL', required=True)
parser.add_argument('-f', dest='output', help='Screenshot filename', required=True)
parser.set_defaults(use_tls=False)
args = parser.parse_args()
#Alternative method using the service
#service = webdriver.chrome.service.Service('./chromedriver')
#service.start()
options = webdriver.ChromeOptions()
options.binary_location = '/usr/bin/google-chrome'
options.add_argument('headless')
options.add_argument('--no-sandbox')
driver = webdriver.Chrome('./chromedriver', chrome_options=options)
#driver = webdriver.Remote(service.service_url, desired_capabilities=options.to_capabilities())
driver.set_window_size(1024, 768) # set the window size that you need
driver.get(args.url)
driver.save_screenshot(args.output)
driver.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment