Created
May 20, 2013 18:53
-
-
Save souri/5614428 to your computer and use it in GitHub Desktop.
Scraping dynamic ajax content with CasperJS
This file contains 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 fs = require('fs'), | |
casper = require('casper').create({ | |
verbose: true, | |
logLevel: "debug", | |
pageSettings: { | |
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.21 (KHTML, like Gecko) Chrome/25.0.1349.2 Safari/537.21' | |
}, | |
clientScripts: ['jquery.min.js'] | |
}); | |
casper.start('http://www.infibeam.com/Books/info/jk-rowling/harry-potter-prisoner-azkaban/9781408810569.html'); | |
casper.on('load.finished', function(status) { | |
console.log("load.finished"); | |
//casper.debugHTML('.marketplaceTablePriceSpan',false); | |
console.log('Starting evaluate...'); | |
var data = casper.evaluate(function() { | |
return [].map.call(document.querySelectorAll(".marketplaceTablePriceSpan"), function(text) { | |
return text.nodeValue(); | |
}); | |
}); | |
console.log(data); | |
//console.log("Done evaluate... count: " + nodes.length); | |
//casper.exit(); | |
}); | |
casper.run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment