Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KgMusic的SeachCollect问题 #20

Open
bey0ndnext opened this issue Aug 10, 2019 · 0 comments
Open

KgMusic的SeachCollect问题 #20

bey0ndnext opened this issue Aug 10, 2019 · 0 comments

Comments

@bey0ndnext
Copy link

目前只下载了第一页,改了一下把所有都下载,望采纳
private static List SearchCollect(string id, int page)
{
List result = new List();
while (true)
{
var url = "http://m.kugou.com/plist/list/?specialid=" + id + "&page=" + page + "&plat=2&json=true";
var html = CommonHelper.GetHtmlContent(url);
if (string.IsNullOrEmpty(html) || html == "null")
{
return null;
}
var json = JObject.Parse(html);

            int total = int.Parse(json["list"]["list"]["total"].ToString());
            int pagesize = int.Parse(json["list"]["pagesize"].ToString());
            page = int.Parse(json["list"]["page"].ToString()); 
            if (json["list"]["list"]["total"].ToString() == "0")
            {
                return null;
            }
            try
            {
                var datas = json["list"]["list"]["info"];
                result.AddRange(GetListByJson(datas));
            }
            catch (Exception ex)
            {
                CommonHelper.AddLog(ex.ToString());
                return null;
            }
            page++;
            if (page * pagesize > total)
                break;
        }
        return result;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant