C# HtmlAgilityPack
C# HtmlAgilityPack
通过url获取网站的document元素,可以通过xpath对元素进行查询
环境准备
Nuget安装
- HtmlAgilityPack
引用
using HtmlAgilityPack;
加载网页中的元素
static void GetHtmlDocument() {
var url = @"https://tpwx.life.cntaiping.com/tpwcp/wcp/wcpalpha/cptk_4109.html";
HtmlWeb web = new HtmlWeb();
var htmlDoc = web.Load(url);
var node = htmlDoc.DocumentNode.SelectSingleNode("//video");
}