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();