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"));
//获取标题
//
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 简单运用,布布扣,bubuko.com
原文:http://www.cnblogs.com/yipeng-yu/p/3865486.html