//获取网页源码
public string getSourceCode(string Url, string CharSet)
{
try
{
//System.GC.Collect();
HttpWebRequest wReq = (HttpWebRequest)WebRequest.Create(Url);
wReq.UserAgent = "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)";
wReq.ContentType = "application/x-www-form-urlencoded";
wReq.Accept = "*/*";
wReq.KeepAlive = true;
wReq.Headers.Add("Accept-Language", "zh-cn,en-us;q=0.5");
WebResponse wResp = wReq.GetResponse();
Stream respStream = wResp.GetResponseStream();
StreamReader reader = new StreamReader(respStream, Encoding.GetEncoding(CharSet));
return reader.ReadToEnd();
}
catch
{
return "";
}
}