2013-03-05 17:10:02 +01:00
|
|
|
/*jshint strict:false*/
|
|
|
|
/*global CasperError console phantom require*/
|
|
|
|
|
|
|
|
/**
|
2012-11-08 17:11:43 +01:00
|
|
|
* This script will capture a screenshot of a twitter account page
|
2013-03-05 17:10:02 +01:00
|
|
|
* Usage: $ casperjs screenshot.js <twitter-account> <filename.[jpg|png|pdf]>
|
2012-11-08 17:11:43 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
var casper = require("casper").create({
|
|
|
|
viewportSize: {
|
|
|
|
width: 1024,
|
|
|
|
height: 768
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var twitterAccount = casper.cli.get(0);
|
|
|
|
var filename = casper.cli.get(1);
|
|
|
|
|
|
|
|
if (!twitterAccount || !filename || !/\.(png|jpg|pdf)$/i.test(filename)) {
|
|
|
|
casper
|
2013-03-05 17:10:02 +01:00
|
|
|
.echo("Usage: $ casperjs screenshot.js <twitter-account> <filename.[jpg|png|pdf]>")
|
2012-11-08 17:11:43 +01:00
|
|
|
.exit(1)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2013-03-05 17:10:02 +01:00
|
|
|
casper.start("https://twitter.com/" + twitterAccount, function() {
|
|
|
|
this.waitForSelector(".stream-container", (function() {
|
2012-11-08 17:11:43 +01:00
|
|
|
this.captureSelector(filename, "html");
|
|
|
|
this.echo("Saved screenshot of " + (this.getCurrentUrl()) + " to " + filename);
|
|
|
|
}), (function() {
|
|
|
|
this.die("Timeout reached. Fail whale?");
|
|
|
|
this.exit();
|
|
|
|
}), 12000);
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.run();
|