public string Get(string url, string Encode = "", int TimeOut = 6000, string cookies = "") { int errortimes = 4; A: try { ClassLoger.Info("HttpUtils.GetAsync", url); System.Net.WebRequest wRequest = System.Net.WebRequest.Create(url); wRequest.Method = "GET"; wRequest.UseDefaultCredentials = true; wRequest.Headers.Set(HttpRequestHeader.UserAgent, UserAgent); wRequest.Headers.Set(HttpRequestHeader.KeepAlive, "true"); wRequest.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.8"); if (!Content_Encoding.IsNull()) { wRequest.Headers.Set(HttpRequestHeader.ContentEncoding, Content_Encoding); } if (!Content_Type.IsNull()) { wRequest.Headers.Set(HttpRequestHeader.ContentType, Content_Type); } if (!Accept.IsNull()) { wRequest.Headers.Set(HttpRequestHeader.Accept, Accept); } if (!Referer.IsNull()) { wRequest.Headers.Set(HttpRequestHeader.Referer, Referer); } switch (HttpProxy) { case HttpProxyType.Default: break; case HttpProxyType.IE: wRequest.Proxy = WebRequest.GetSystemWebProxy(); break; case HttpProxyType.None: wRequest.Proxy = null; break; } if (url.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) { } wRequest.Timeout = TimeOut; if (!string.IsNullOrEmpty(cookies)) { wRequest.Headers.Set(HttpRequestHeader.Cookie, cookies); } Encoding encoder = Encoding.Default; if (!Encode.IsNull()) { encoder = Encoding.GetEncoding(Encode); } System.Net.WebResponse wResp = wRequest.GetResponse(); System.IO.Stream respStream = wResp.GetResponseStream(); using (System.IO.StreamReader reader = new System.IO.StreamReader(respStream, encoder)) { return(reader.ReadToEnd()); } } catch (Exception ex) { ClassLoger.Error("HTTPHelper.Get", ex); if (errortimes > 0) { errortimes--; goto A; } } return(string.Empty); }