日期:2014-05-17 浏览次数:20737 次
public static string GetHtml(string uri, string BianMa)
{
string result = string.Empty;
try
{
string ip = string.Empty;
string port = string.Empty;
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(new Uri(uri));
req.Proxy = null;
req.Timeout = 10000;
req.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
req.ContentType = "application/x-www-form-DownUrlencoded";
req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322)";
HttpWebResponse response = (HttpWebResponse)req.GetResponse();
Stream ReceiveStream = response.GetResponseStream();
StreamReader sr = new StreamReader(ReceiveStream, Encoding.GetEncoding(BianMa));
result = sr.ReadToEnd();
response.Close();
ReceiveStream.Close();
sr.Close();
}
catch
{
return "";
}
return result;
}