示例#1
0
        private static List<GMDTalkShow> LoadCatagory(string catagoryUrl)
        {
            string html = GMDTalkShow.GetPageHtmlAsync(catagoryUrl).Result;
            HtmlDocument htmlDoc = new HtmlDocument();
            htmlDoc.LoadHtml(html);

            HtmlNode node = htmlDoc.GetElementbyId("main");
            var nodes = node.SelectNodes("article/div/p").Where(n =>
            {
                var property = n.Attributes["class"];
                return property != null && property.Value == "read-more";
            });


            List<GMDTalkShow> talkShowList = new List<GMDTalkShow>();
            foreach (HtmlNode n in nodes)
            {
                var aNode = n.SelectNodes("a").First();
                if (aNode != null)
                {
                    string url = aNode.GetAttributeValue("href", "");
                    if (url != "")
                    {
                        GMDTalkShow talkShow = new GMDTalkShow(url);
                        bool result = talkShow.LoadFromUrlAsync().Result;
                        if (result)
                        {
                            talkShowList.Add(talkShow);
                        }
                    }
                }
            }
            return talkShowList;
        }
示例#2
0
 public static List<GMDTalkShow> LoadAll1()
 {
     string html = GMDTalkShow.GetPageHtmlAsync("http://gmdwith.us").Result;
     HtmlDocument htmlDoc = new HtmlDocument();
     htmlDoc.LoadHtml(html);
     HtmlNode node = htmlDoc.GetElementbyId("text-4");
     HtmlNodeCollection nodes = node.SelectNodes("div/a");
     List<GMDTalkShow> talkShowList = new List<GMDTalkShow>();
     foreach (HtmlNode n in nodes)
     {
         string url = n.GetAttributeValue("href", "");
         if (url != "")
         {
             GMDTalkShow talkShow = new GMDTalkShow(url);
             bool result = talkShow.LoadFromUrlAsync().Result;
             if (result)
             {
                 talkShowList.Add(talkShow);
             }
         }
     }
     return talkShowList;
 }