1

私のasp.net WebサイトでYouTubeチャンネルの購読者数を取得する必要があります. :

http://gdata.youtube.com/feeds/api/users/PageName

しかし、ブラウザで開いても何も提供されず、何の助けも開かれません。

使用できる特別なライブラリまたは API はありますか?

4

1 に答える 1

1

できることは次のとおりです。

System.Net.WebClient wb = new System.Net.WebClient();
string str = wb.DownloadString("http://gdata.youtube.com/feeds/api/users/TheNewYorkTimes");
Response.Write(getCount(str));

public static string getCount(string video)
        {
            if (video.Contains("="))
            {
                string str = "subscriberCount='";
                string videoid = video.Substring(video.IndexOf("subscriberCount") + str.Length);
                if (videoid.Contains("'"))
                {
                    videoid = videoid.Remove(videoid.IndexOf("'"));
                    return videoid;
                }
                else
                {
                    return "";
                }
            }
            else
            {
                return "";
            }
        }
于 2012-11-14T13:56:33.170 に答える