C# 根据链接提取div内容

安装NuGet包    HtmlAgilityPack

 

var wc = new WebClient();
wc.Encoding = Encoding.GetEncoding("UTF-8"); //转格式
var html = wc.DownloadString(url); //获取内容
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(html);
HtmlNode nodeinfo = doc.GetElementbyId("content");//获取该id内容
string htmlstr = nodeinfo.OuterHtml;

 

posted @ 2019-02-25 19:07  _小马哥  阅读(652)  评论(0编辑  收藏  举报