Пример #1
0
        public static ObservableCollection <LuoVol> GetVolListFromHtml(string html)
        {
            var vollist = new ObservableCollection <LuoVol>();

            HtmlDocument doc = new HtmlDocument();

            doc.LoadHtml(html);
            //查找节点
            var titleNode = doc.DocumentNode.SelectSingleNode("//div[@class='vol-list']");
            var list      = titleNode.SelectNodes("./div[@class='item']");

            foreach (var i in list)
            {
                var cover = i.SelectSingleNode("./a/img").GetAttributeValue("src", "");
                var Node1 = i.SelectSingleNode("./div/a");
                // /html/body/div[3]/div/div[1]/div[2]/div[2]/a/img
                var volurl = Node1.GetAttributeValue("href", "");
                var title  = Node1.GetAttributeValue("title", "");

                var volnum = StringHelper.SpliteForm2String(Node1.InnerText, ".", " ");

                var commentcount = i.SelectSingleNode("./div/span[1]").InnerText.Replace("\n", "").Replace("\t", "");
                var favdcount    = i.SelectSingleNode("./div/span[2]").InnerText.Replace("\n", "").Replace("\t", "");

                var vol = new LuoVol(cover, volnum, volurl, title, commentcount, favdcount);

                //if (vol.VolUrl != null)
                //{
                //    var http_detail = new HttpClient();
                //    http_detail.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36");
                //    var http_response = await http_detail.GetAsync(vol.VolUrl);

                //    string result = http_response.Content.ReadAsStringAsync().Result;
                //    vol.GetDetailVol(result);
                //}

                vollist.Add(vol);
            }

            return(vollist);
        }
Пример #2
0
        public static ObservableCollection <LuoVol> GetVolListFromHtml_w(string html)
        {
            var vollist = new ObservableCollection <LuoVol>();

            HtmlDocument doc = new HtmlDocument();

            doc.LoadHtml(html);
            //查找节点
            var list = doc.DocumentNode.SelectNodes("//div[@class='thumbnail theborder']");

            foreach (var i in list)
            {
                //http://luoow.wxwenku.com/100/cover.jpg
                //http://luoow.wxwenku.com/99/cover_min.jpg
                var cover = i.SelectSingleNode("./a/img").GetAttributeValue("src", "").Replace("_min", "");
                if (!cover.Contains("http:"))
                {
                    cover = "http:" + cover;
                }

                var Node1 = i.SelectSingleNode("./div/p/a");

                //var volnum = Node1.GetAttributeValue("href", "").Replace("/", "");
                var volnum = StringHelper.SpliteForm2String(Node1.InnerText, ".", " ");
                var volurl = "https://www.luoow.com" + Node1.GetAttributeValue("href", "");
                var title  = Node1.GetAttributeValue("title", "");

                //Special for /e and /r


                var vol = new LuoVol(cover, volnum, volurl, title);

                vollist.Add(vol);
            }

            return(vollist);
        }