Skip to content

Instantly share code, notes, and snippets.

@joemarchese
Created June 12, 2017 14:34
Show Gist options
  • Select an option

  • Save joemarchese/68abb17f505831c84e98dde0bcccefc6 to your computer and use it in GitHub Desktop.

Select an option

Save joemarchese/68abb17f505831c84e98dde0bcccefc6 to your computer and use it in GitHub Desktop.
Selenium-PhantomJS Screenshooter
import os
import requests
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
dcap = dict(DesiredCapabilities.PHANTOMJS)
driver = webdriver.PhantomJS(os.path.join(os.getcwd() + '\phantomjs.exe'), desired_capabilities=dcap)
sleep(2)
driver.set_window_size(1024, 768)
driver.get('http://www.google.com/')
driver.save_screenshot('test.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment