Skip to content

Instantly share code, notes, and snippets.

@eewee
Created October 14, 2016 19:28
Show Gist options
  • Save eewee/ccdf2af7f6914fe702a02c727b318996 to your computer and use it in GitHub Desktop.
Save eewee/ccdf2af7f6914fe702a02c727b318996 to your computer and use it in GitHub Desktop.
casperjs : screenshot
var casper = require('casper').create();
var utils = require('utils');
var urls = [
'http://www.eewee.fr/',
'http://www.eewee.fr/page/2/',
];
var i = 0;
casper.start();
casper.userAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X)');
casper.each(urls, function(self, url){
casper.thenOpen(url, function(){
// Prendre une photo
this.viewport(1800, 1200);
this.capture('eewee_capture_'+i+'_all.jpg');
this.viewport(1024, 768);
this.captureSelector('eewee_capture_'+i+'_1024x768.jpg', 'article');
this.viewport(800, 600);
this.captureSelector('eewee_capture_'+i+'_800x600.jpg', 'article');
this.viewport(400, 300);
this.captureSelector('eewee_capture_'+i+'_400x300.jpg', 'article');
this.echo( this.status(true) );
i++;
});
// Scroll
this.scrollToBottom();
});
casper.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment