Skip to content

Instantly share code, notes, and snippets.

@HomerJSimpson
Created January 6, 2015 18:03
Show Gist options
  • Save HomerJSimpson/b5b83977ad5b667baf75 to your computer and use it in GitHub Desktop.
Save HomerJSimpson/b5b83977ad5b667baf75 to your computer and use it in GitHub Desktop.
Scrape envato author page for sales and revenue
/*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