Created
October 7, 2013 19:48
-
-
Save denysonique/6873797 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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