先引用HtmlAgilityPack.dll,没有的话下载一下
直接上代码
var doc = new HtmlDocument(); doc.LoadHtml(html);//html字符串 //获取标签里的值 var nodes = doc.DocumentNode.SelectSingleNode("//div[@class=‘list-container‘]").InnerText; //获取一个多个节点,进行遍历 var nodes_gjjl = doc_gjjl.DocumentNode.SelectNodes("//div[@class=‘project-follow‘]"); foreach (var item in nodes_gjjl) { string gjjl_time = item.SelectSingleNode("./table/tbody/tr[1]/td[2]/span").InnerText; }