.NET Core HtmlAgilityPack HTML????????
???????????? ???????[ 2016/6/27 13:40:10 ] ??????????????????? .NET
????????.NET Core ???????????????????????? .NET Core??????HtmlAgilityPack ?????????????????????Щ?????????????? .NET Core ?С????????????????? .NET Core ???Щ?????
????.NET Core?? HtmlAgilityPack HTML?????????????? HtmlAgilityPack Core RC2
????HtmlAgilityPack ????
????HtmlAgilityPack?????????.Net?????????????????????????????????????????html?????
?????????fork ?????????????????????Щ?????????
??????????? http://htmlagilitypack.codeplex.com/
????GitHub?? https://github.com/linezero/HtmlAgilityPack
????HtmlAgilityPack?ж?λ???????????Xpath??????Xpath??????ο?????????http://www.w3school.com.cn/xpath/xpath_syntax.asp ??
???????????????????????
????1????????title??doc.DocumentNode.SelectSingleNode(“//title”).InnerText;
?????????XPath??“//title”???????title???SelectSingleNode???????????????????
????2????????е???????doc.DocumentNode.Descendants(“a”)
????3?????name?kw??input?????????getElementsByName()??
????var kwBox = doc.DocumentNode.SelectSingleNode(“//input[@name=’kw’]”);
????.NET Core ???HtmlAgilityPack
?????????????????ó???
?????????? HtmlAgilityPack ?????????????????????á?
????????????????????á??????????????????????н?????
public static void Main(string[] args)
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
HtmlWeb web = new HtmlWeb();
var doc = web.LoadFromWebAsync("http://news.cnblogs.com/").Result;
var nodes = doc.DocumentNode.SelectNodes("//div[@id='news_list']/div/div[2]/h2/a");
foreach (var item in nodes)
{
Console.WriteLine($"????{item.InnerText} ?????{item.Attributes["href"].Value}" );
}
Console.ReadKey();
}
????HtmlAgilityPack .NET Core RC2
????GitHub?? https://github.com/linezero/HtmlAgilityPack
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11