예제 #1
0
        public List <string> GetHuyaUserName()
        {
            List <string> huyaUserName = new List <string>();

            //string huyaUrl = "http://www.huya.com/cache.php?m=Tag&do=getGameTagLiveByPage&gameId=6&tagId=22&page=1";

            for (int i = 0; i <= 10; i++)
            {
                string huyaUrl = "http://www.huya.com/cache.php?m=Game&do=ajaxGameLiveByPage&gid=6&page=" + i.ToString() + "&pageNum=1";

                string huyaresult = HttpFunction.Get(huyaUrl, Encoding.UTF8, 25600000);

                HuyaJson sModel = JsonSerializer.DeserializeFromString <HuyaJson>(huyaresult);

                if (sModel != null && sModel.data != null && sModel.data.list != null)
                {
                    huyaUserName.AddRange(sModel.data.list.Select(e => e.nick).ToList());
                }
            }
            return(huyaUserName);
        }
예제 #2
0
파일: Program.cs 프로젝트: tuolei911/YY.TV
        static void Main(string[] args)
        {
            string pandaUrl = "http://www.panda.tv/cate/war3";
            //string huyaUrl = "http://www.huya.com/g/war3#tag22";
            string huyaUrl = "http://www.huya.com/cache.php?m=Tag&do=getGameTagLiveByPage&gameId=6&tagId=22&page=1";


            string result = HttpFunction.Get(pandaUrl, Encoding.UTF8);


            Regex           reg = new Regex(@"(?<=<span class=""video-nickname"">)(.*?)(?=</span>)", RegexOptions.IgnoreCase);//[^(<td>))]
            MatchCollection mc  = reg.Matches(result);

            List <string> pandaUserName = new List <string>();

            foreach (Match m in mc)
            {
                pandaUserName.Add(m.Value);
            }

            string huyaresult = HttpFunction.Get(huyaUrl, Encoding.UTF8);


            HuyaJson sModel = JsonSerializer.DeserializeFromString <HuyaJson>(huyaresult);


            Regex reghuya = new Regex(@"<i class=""nick"" title=""[\s\S]*?"">", RegexOptions.IgnoreCase);//[^(<td>))]
            // Regex reghuya = new Regex(@"(^|,)\s*isNotLive\s*(,|$)", RegexOptions.IgnoreCase);
            List <string>   huyaUserName = new List <string>();
            MatchCollection huyamc       = reghuya.Matches(huyaresult);

            foreach (Match m in huyamc)
            {
                huyaUserName.Add(m.Value.Replace(@"<i class=""nick"" title=""", "").Replace(@""">", ""));
                //huyaUserName.Add(m.Value);
            }
        }