-
-
Save bogdanRada/f4c8f9defd289d7d49d6c44b205b8f82 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//create new webpage object | |
var page = new WebPage(); | |
//load the page | |
page.open('http://espn.go.com/nfl', function (status) { | |
//fire callback to take screenshot after load complete | |
page.render('espn.png'); | |
//finish | |
phantom.exit(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To run this script, navigate to where the script lives on your server and run the following command. We run "Xvfb -screen 0 1024x768x24&" first to set the parameters of our Xvfb screen buffer. This is basically a virtual screen that allows us to emulate a window environment. Then we call the script with "DISPLAY=:0 phantomjs --load-plugins=yes shotty.js" to ensure Phantom runs in the buffer. PhantomJS will execute our script and save our screenshot in the same folder the script is in. If everything went well our screenshot of espn.com should look just like the real thing.