XPath

https://www.cnblogs.com/yukaizhao/archive/2011/07/25/xpath.html

 

var result = GetStringByUrl(textBox1.Text.Trim());               
                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(result);
                //HtmlAgilityPack.HtmlNodeCollection HNc = doc.DocumentNode.SelectNodes("//div[@class='house-title']/h1");

                var titleNode = doc.DocumentNode.SelectSingleNode("//h1[@class='c_333 f20']").InnerText;
                var chanquan = doc.DocumentNode.SelectSingleNode("//span[contains(text(),'产权年限')]/following-sibling::span").InnerText;
                var xiaoqu = doc.DocumentNode.SelectSingleNode("//span[@class='c_000 mr_10']").InnerHtml;

                var mianqi = doc.DocumentNode.SelectSingleNode("//span[contains(text(),'房本面积')]/following-sibling::span").InnerHtml;
                var maidian = doc.DocumentNode.SelectSingleNode("//p[@class='pic-desc-word']").InnerHtml.Replace("<br>","");
                var chaoxiang = doc.DocumentNode.SelectSingleNode("//span[contains(text(),'建筑年代(暂无信息)')]/preceding-sibling::span").InnerHtml;
                var price = doc.DocumentNode.SelectSingleNode("//p[@class='house-basic-item1']/span").InnerHtml.Replace("<b>","").Replace("</b>","");
                var shiting = doc.DocumentNode.SelectSingleNode("//p[@class='room']/span[contains(text(),'室')]").InnerText;
                var jiaoyi = doc.DocumentNode.SelectSingleNode("//span[contains(text(),'交易')]/following-sibling::span").InnerText;
                var jiege = doc.DocumentNode.SelectSingleNode("//span[@class='unit']").InnerHtml;

 

posted @ 2018-05-28 15:44  你的斗志并没有失去  阅读(122)  评论(0编辑  收藏  举报