Skip to content

Instantly share code, notes, and snippets.

@jonaslund
Created September 17, 2016 11:14
Show Gist options
  • Save jonaslund/6c9826d4e36849c42b24598c818a53d3 to your computer and use it in GitHub Desktop.
Save jonaslund/6c9826d4e36849c42b24598c818a53d3 to your computer and use it in GitHub Desktop.
var url = 'http://url.com';
var screenIndex = 0;
var amountOfFrames = 30 * 60 * 60;
// var amountOfFrames = 12000;
// var amountOfFrames = 1000;
//frames, one minute, minutes
var page = require('webpage').create();
// page.viewportSize = { width: 786, height: 1024 };
page.viewportSize = { width: 1080, height: 1920 };
// page.clipRect = { top: 0, left: 0, width: 786, height: 1024 };
page.clipRect = { top: 0, left: 0, width: 1080, height: 1920 };
page.settings.userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36';
page.open(url, function(status) {
if (status == 'success') {
// if (page.injectJs('jquery.js')) {
render();
// }
// else {
// done('cannot include jquery');
// }
}
else {
done('cannot load page');
}
});
page.onConsoleMessage = function(msg, lineNum, sourceId) {
console.log('CONSOLE: ' + msg + ' (from line #' + lineNum + ' in "' + sourceId + '")');
};
function render() {
if (screenIndex < amountOfFrames) {
var screenIndexCorrected = screenIndex + 1;
console.log('rendering frame ' + screenIndexCorrected + ' of ' + amountOfFrames);
page.evaluate(function() {
jQuery('#btn-tick').click();
});
screenIndex++;
page.render('folder/' + screenIndex + '.png');
setTimeout(function() {
render();
}, 16);
}
else {
done('done rendering :)');
}
}
function done(msg) {
if (msg) {
console.log(msg);
}
phantom.exit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment