Skip to content

Instantly share code, notes, and snippets.

@tristaaan tristaaan/duo_scraper.js
Last active Nov 18, 2016

Embed
What would you like to do?
Duolingo word scraper
// found from http://pastebin.com/jnEViBPz
// simple run in console on duolingo homepage
var $words = $('<table><thead><tr><th>Language</th><th>Category</th><th>Word</th><th>Strength</th></thead><table>');
var ld=duo.user.attributes.language_data;
var count = 0;
var waiting = 0;
for(l in ld){
waiting = ld[l].skills.models.length;
ld[l].skills.models.forEach(function(e){
var t=e.attributes;
if(t.progress_percent>0){
$.get("/skills/"+t.language+"/"+t.url_title,function(e){
e.path.forEach(function(e){
if(e.words&&e.strength>0){
e.words.forEach(function(n){
count++;
var r="<tr>";r+="<td>"+l+"</td>";
r+="<td>"+t.name+"</td>";
r+="<td>"+n+"</td>";
r+="<td>"+e.strength+"</td>";
r+="</tr>";
$words.append(r)
})
}
})
if(--waiting===0) {
$words.append('<tr><td colspan="3">TOTAL</td><td>'+count+'</td></tr>');
$('body').html($words);
}
})
} else {
waiting--;
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.