private HttpWebResponse GetResponse()
 {
     foreach (var sub in Url)
     {
         try
         {
             var request = WebRequest.Create(sub) as HttpWebRequest;
             request.Referer   = Referer;
             request.UserAgent = UserAgent;
             request.Timeout   = 10000;
             if (UserCookies != null)
             {
                 request.CookieContainer = new CookieContainer();
                 foreach (var key in UserCookies.GetKeys())
                 {
                     var ck = new Cookie(key, UserCookies.GetCookie(key))
                     {
                         Domain = Domain
                     };
                     request.CookieContainer.Add(ck);
                 }
             }
             return((HttpWebResponse)request.GetResponse());
         }
         catch (WebException ex)
         {
             if (ex.Message.Contains("超时") || ex.Message.Contains("Timeout"))
             {
                 return(GetResponse());
             }
         }
     }
     return(null);
 }
Exemplo n.º 2
0
 private HttpWebResponse GetResponse()
 {
     foreach (var sub in Url)
     {
         try
         {
             var request = WebRequest.Create(sub) as HttpWebRequest;
             request.Referer   = Referer;
             request.UserAgent = UserAgent;
             if (UserCookies != null)
             {
                 request.CookieContainer = new CookieContainer();
                 foreach (var key in UserCookies.GetKeys())
                 {
                     var ck = new Cookie(key, UserCookies.GetCookie(key))
                     {
                         Domain = Domain
                     };
                     request.CookieContainer.Add(ck);
                 }
             }
             return((HttpWebResponse)request.GetResponse());
         }
         catch
         {
         }
     }
     return(null);
 }