日期:2014-05-20  浏览次数:20815 次

请问C#怎么抓取网页的内容。
请问C#怎么抓取网页的内容,或者能给点网站学习一下噢

------解决方案--------------------
用HttpWebRequest得到网页源代码,用正则取出你想要的内容
------解决方案--------------------
try..

HttpWebRequest request = (HttpWebRequest)WebRequest.Create( "http://www.baidu.com ");
request.Method = "GET ";
WebResponse response = request.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream(), System.Text.Encoding.GetEncoding( "GB2312 "));
string content = sr.ReadToEnd();
sr.Close();
Console.WriteLine(content);