Skip to content

Instantly share code, notes, and snippets.

@denysonique
Created October 7, 2013 19:48
Show Gist options
  • Save denysonique/6873797 to your computer and use it in GitHub Desktop.
Save denysonique/6873797 to your computer and use it in GitHub Desktop.
getMusic = function (link, pages) {
console.log('Initializing Music retrieval...');
for (pageX = 0; pageX <= pages; pageX++) {
url = link + pageX;
getPage(pageX);
};
};
function getPage (pageX) {
console.log('enter get page');
request(url, function(err, response, body) {
if(!err && response.statusCode == 200) {
$ = cheerio.load(body);
getSongs(body)
} else {
throw err;
}
});
};
function getSongs(body) {
console.log('enter get songs');
for (x = 0; x <= songCount; x++) {
var songName = $('td.channel:first-child').parent().nextAll().eq(x).children('td:nth-child(2)').text();
var songArtist = $('td.channel:first-child').parent().nextAll().eq(x).children('td:nth-child(3)').text();
var dateAdded = $('td.channel:first-child').parent().nextAll().eq(x).children('td:nth-child(4)').text();
list.push({'name': songName, 'artist': songArtist, 'date': dateAdded});
x++;
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment