日期:2014-05-17  浏览次数:20737 次

winform 请求网页问题
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;
    }




请教各位大牛,程序请求网页,被360检测到,这样被用户看到很不好,有什么办法能解决吗,请求代码如上,用WebBrowser控件也出现同样的情况。。

------解决方案--------------------
是网址有问题吧,你试试baidu.com