HtmlAgilityPack 简单运用

WebClient client = new WebClient();
MemoryStream ms = new MemoryStream(client.DownloadData("http://www.cnblogs.com/"));
HtmlDocument doc = new HtmlDocument();
doc.Load(ms, Encoding.GetEncoding("UTF-8"));
//获取标题

//HtmlAgilityPack 简单运用
HtmlNodeCollection nodes = doc.DocumentNode.SelectNodes("/html[1]/body[1]//div[@id=\"nav_menu\"]/a");
foreach (HtmlNode node in nodes)
{
Console.WriteLine(node.InnerText);
}
doc = null;
client = null;
ms.Close();
Console.ReadLine();

HtmlAgilityPack 简单运用

上一篇:团队——League of Programers简介


下一篇:Linux零碎知识