Skip to content

Instantly share code, notes, and snippets.

@Azlirn
Created September 1, 2016 20:33
Show Gist options
  • Save Azlirn/06c614e6d1d82f6fe0976c318ba06420 to your computer and use it in GitHub Desktop.
Save Azlirn/06c614e6d1d82f6fe0976c318ba06420 to your computer and use it in GitHub Desktop.
A snippet that allows users to take a screenshot of a website after it opens in Firefox
from PIL import ImageGrab
import webbrowser
import time
browser = 'firefox'
url = 'https://twitter.com/cyb3rdude'
webbrowser.get(browser).open_new_tab(url)
# Wait a few seconds to allow the page to load
time.sleep(2)
# Bounding box optimized to only grab the tweet url and tweet in the screenshot.
image = ImageGrab.grab(bbox=(50, 130, 2200, 1200))
# Save the new image
image.save("image.png")
@Azlirn
Copy link
Author

Azlirn commented Sep 2, 2016

Only supported on OSX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment