Created
April 22, 2016 20:14
-
-
Save dealingwith/9f216bbba996f2fd7592e0d1f251fa1c to your computer and use it in GitHub Desktop.
Failing to get Facebook screenshots via Casper
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 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