Skip to content

Instantly share code, notes, and snippets.

@iMyon
Created April 6, 2015 15:30
Show Gist options
  • Save iMyon/ea93599a1126fe8fe4cd to your computer and use it in GitHub Desktop.
Save iMyon/ea93599a1126fe8fe4cd to your computer and use it in GitHub Desktop.
//referer limit page 5, sad
var pages = $(".all_page span:last").text().match(/共(\d+)条/)[1] / 25;
var uid = location.href.match(/lib-song\/u\/(\d+)/)[1];
pages = Math.ceil(pages);
var index = 1;
var i = 1;
var song_obj = [];
function getData(url){
$.get(url, function(res){
$(res).find("tr[id^=lib_song]").each(function(){
var author = $(this).find(".song_name a:eq(1)");
var name = $(this).find(".song_name a:eq(0)");
song_obj.push({author:author, name:name});
});
if(++index <= pages) getData("http://www.xiami.com/space/lib-song/u/"+ uid +"/page/"+index);
else show();
});
}
getData("http://www.xiami.com/space/lib-song/u/"+ uid +"/page/"+index);
function show(){
console.log(i++);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment