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);
 }
 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);
 }
示例#3
0
 // PUT: api/UserInputData/5
 public void Put(int id, [FromBody] UserCookies value)
 {
     db.Entry(value).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
 }
示例#4
0
 // POST: api/UserInputData
 public void Post([FromBody] UserCookies value)
 {
     db.UserCookies.Add(value);
     db.SaveChanges();
 }