Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@penk
Created October 2, 2014 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save penk/ce7357728a0274ae0e68 to your computer and use it in GitHub Desktop.
Save penk/ce7357728a0274ae0e68 to your computer and use it in GitHub Desktop.
8comic downloader written in casperjs
// Usage: casperjs 8comic.js http://new.comicvip.com/show/cool-1050.html
var casper = require('casper').create({
pageSettings: {
webSecurityEnabled: false
}
});
var pages, currentPage;
casper.start(casper.cli.args[0], function(){
pages = this.evaluate(function(){
return document.querySelector("#pageindex").length
});
});
casper.on('load.finished', function (status) {
if (status === 'success') {
var img = this.evaluate(function(){ return document.querySelector("#TheImg").src });
this.echo(img, 'INFO');
this.download(img, img.split('/').reverse()[0]);
currentPage = this.evaluate(function(){ return document.querySelector("#pageindex").selectedIndex });
if (currentPage === pages -1 ) {
casper.exit();
}
this.then(function(){ this.click('#next') })
}
});
casper.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment