Skip to content

Instantly share code, notes, and snippets.

@jexp
Created June 1, 2016 22:51
Show Gist options
  • Save jexp/b0800bd9585b7d06def4a50ff1cd3579 to your computer and use it in GitHub Desktop.
Save jexp/b0800bd9585b7d06def4a50ff1cd3579 to your computer and use it in GitHub Desktop.
scrape twitter stats data from https://analytics.twitter.com/user/<name>/home
// On https://analytics.twitter.com/user/<name>/home
// run this in developer console
// essentially:
$(".home-group-row").map(function(x) { var group=$(this); return group.find(".home-group-header").text()+","+ ['tweets','tweetviews','profile-views','mentions','followers'].map(function(tag) { return group.find(".metric-"+tag).text(); }).join(","); }).toArray().join("\n")
// prettied up:
var metrics = ['tweets','profile-views','mentions','followers','tweetviews'];
"month\t" + metrics.join("\t") + "\n" +
$(".home-group-row")
.map(function(x) {
var group=$(this);
var values = metrics.map(function(tag) { return group.find(".metric-"+tag).text().replace(",","").replace(/(.+)K/,"=$1*1000"); }).join("\t");
return group.find(".home-group-header").text().replace(" Summary","")+"\t"+ values
}).toArray().join("\n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment