Take a screenshot from a website from commandline or with python

I had difficulty getting Ghost to take a screenshot consistently on a headless Centos VM. Selenium and PhantomJS worked for me:

from selenium import webdriver
br = webdriver.PhantomJS()
br.get('http://www.stackoverflow.com')
br.save_screenshot('screenshot.png')
br.quit

You can use ghost.py if you like. https://github.com/jeanphix/Ghost.py

Here is an example of how to use it.

from ghost import Ghost
ghost = Ghost(wait_timeout=4)
ghost.open('http://www.google.com')
ghost.capture_to('screen_shot.png')

The last line saves the image in your current directory.

Hope this helps