Skip to content

Instantly share code, notes, and snippets.

@cakenggt
Last active November 28, 2015 15:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cakenggt/5c598ef1389405c526d5 to your computer and use it in GitHub Desktop.
Save cakenggt/5c598ef1389405c526d5 to your computer and use it in GitHub Desktop.
Duolingo Vocab Scraper
var skillList = [];
var learningLanguage = duo.user.attributes.learning_language
var skills = duo.user.attributes.language_data[learningLanguage].skills.models;
skills.sort(function(a, b){
if (a.attributes.coords_y == b.attributes.coords_y){
return a.attributes.coords_x-b.attributes.coords_x;
}
else{
return a.attributes.coords_y-b.attributes.coords_y;
}
});
var complete = 0;
var available = 0;
var titleMap = {};
for (var x = 0; x < skills.length; x++){
var skill = skills[x];
var url_title = skill.attributes.url_title;
titleMap[skill.attributes.title] = x;
if (!skill.attributes.locked){
available++;
$.getJSON('https://www.duolingo.com/skills/'+learningLanguage+'/'+url_title, function(response){
var wordList = [];
for (var y = 0; y < response.path.length-1; y++){
var pathObj = response.path[y];
wordList = wordList.concat(pathObj.words);
}
skillList[titleMap[response.title]]= {"title":response.title, "words":wordList};
})
.always(function(){
complete++;
if (complete == available){
for (var z = 0; z < skillList.length; z++){
var result = skillList[z];
console.log('Skill Name: ' + result.title);
for (var w = 0; w < result.words.length; w++){
console.log(result.words[w]);
}
}
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment