下载地址:http://htmlagilitypack.codeplex.com/
1.添加HtmlAgilityPack.dll引用(引用类using HtmlAgilityPack;)。
2.简单根据html中input的id获取value代码如下:
// 模拟用户请求
WebClient webClient = new WebClient();
webClient.Encoding = System.Text.Encoding.UTF8;
string htmlContext = webClient.DownloadString("http://stone_w.cnblogs.com/");
webClient.Credentials = CredentialCache.DefaultCredentials; // 添加授权证书
webClient.Headers.Add("User-Agent", "Microsoft Internet Explorer");
webClient.Headers.Add("Host", "www.cnblogs.com"); // 获取html元素(htmlContext为html页面字符串)
HtmlDocument htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(htmlContext); // 加载html页面
HtmlNode navNode = htmlDoc.GetElementbyId("id名称");
Response.Write(navNode.Attributes["value"].Value);