Last active
December 27, 2015 01:28
-
-
Save hugsy/7244785 to your computer and use it in GitHub Desktop.
Headless browser screenshoter
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
#!/usr/bin/env python2 | |
import os | |
import sys | |
import time | |
import subprocess | |
try: | |
from pyvirtualdisplay import Display | |
except ImportError: | |
print("[-] pip install PyVirtualDisplay") | |
exit(1) | |
try: | |
from selenium import webdriver | |
except ImportError: | |
print("[-] pip install selenium") | |
exit(1) | |
WIDTH = 1024 | |
HEIGHT = 768 | |
if __name__ == "__main__": | |
display = Display(visible=0, size=(WIDTH, HEIGHT)) | |
display.start() | |
browser = webdriver.Firefox() | |
urls = sys.argv[1:] | |
for url in urls: | |
try: | |
name = './thumb_' + url.replace("://","_") + '.png' | |
browser.get(url) | |
browser.save_screenshot(name) | |
except: | |
pass | |
browser.quit() | |
display.stop() | |
exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment