Skip to content

Instantly share code, notes, and snippets.

@garciamax
Created October 3, 2013 13:12
Show Gist options
  • Save garciamax/6809596 to your computer and use it in GitHub Desktop.
Save garciamax/6809596 to your computer and use it in GitHub Desktop.
screenshot multiple urls with phantomjs.
var page = require('webpage').create();
page.onConsoleMessage = function (msg) {
// console.log(msg);
};
var items = [
{name:'espn',url:'http://espn.go.com/nfl/'},
{name:'google',url:'http://google.com/'},
];// array with items.
(function recursion(){
if(items.length == 0) phantom.exit();
var _item = items[0];
page.open(_item.url, function() {
console.log('opened '+_item.name);
page.render('screenshot_'+_item.name+'.png');
items.shift();
recursion();
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment