Created
December 6, 2012 18:47
-
-
Save moltar/4227007 to your computer and use it in GitHub Desktop.
screen 10 times
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
var url = 'http://www.google.com'; | |
var prefix = 'CA'; | |
var totalScreenshots = 10; | |
var screenshotDelay = 10; // seconds | |
var i = 0; | |
function makeScreenshot(url, filename, callback) { | |
var page = new WebPage(); | |
page.settings.userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0'; | |
page.open(url, function(status) { | |
var timeoutId = setInterval(function() { | |
page.render(filename); | |
clearInterval(timeoutId); | |
callback.apply(); | |
}, 1000 * screenshotDelay); | |
}); | |
} | |
function process() { | |
if (++i <= totalScreenshots) { | |
var filename = prefix + '_' + i + '.png'; | |
console.log(filename); | |
makeScreenshot(url, filename, process); | |
} else { | |
phantom.exit(); | |
} | |
} | |
process(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment