Skip to content

Instantly share code, notes, and snippets.

@dealingwith
Created April 22, 2016 20:14
Show Gist options
  • Save dealingwith/9f216bbba996f2fd7592e0d1f251fa1c to your computer and use it in GitHub Desktop.
Save dealingwith/9f216bbba996f2fd7592e0d1f251fa1c to your computer and use it in GitHub Desktop.
Failing to get Facebook screenshots via Casper
var casper = require("casper").create(),
urls = [
'https://www.facebook.com/ModernApartmentCommunity/',
'https://www.facebook.com/ModernApartmentCommunity/reviews/'
'http://modernmsg.com',
'http://modernmsg.com/rewards'
],
saveDir = 'shots'
casper.start();
casper.each(urls, function(self, url) {
this.viewport(1024, 768);
casper.thenOpen(url, function() {
this.echo('Opening ' + url);
//give some time for the page to load
casper.wait(10000, function() {
var ACfilename = saveDir + '/' + url.replace(/[^a-zA-Z0-9]/gi, '-').replace(/^https?-+/, '') + ".png";
this.capture(ACfilename, {top: 0,left: 0,width: 1024, height: 768});
this.echo('snapshot taken');
});
});
});
casper.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment