Created
January 6, 2015 18:03
-
-
Save HomerJSimpson/b5b83977ad5b667baf75 to your computer and use it in GitHub Desktop.
Scrape envato author page for sales and revenue
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
/*jslint white:true, unparam:true, browser:true */ | |
/*global $, casper, console, jQuery */ | |
(function() { | |
"use strict"; | |
var casper = require('casper').create(); | |
console.log("Starting..."); | |
casper.start('http://themeforest.net/user/oxygenna/portfolio?direction=desc&order_by=sortable_at&view=grid', function() { | |
console.log('scraping'); | |
var rv = this.evaluate(function() { | |
var saleCount = $('.sale-count').map(function() { | |
return { | |
name : $('h3', $(this).parent().prev()).text(), | |
sales : $(this).text().replace(/ Sales/, ''), | |
price : $(this).next().text().replace(/\$/, '') | |
}; | |
}).toArray(); | |
return saleCount.map(function(v, i) { | |
return [ v.name, v.sales, v.price ].join('\t'); | |
}).join('\n'); | |
}); | |
console.log(rv); | |
}); | |
casper.run(function() { | |
console.log('done'); | |
this.exit(); | |
}); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment