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