我正在尝试使用http请求复制登录网站。我的问题是,通过浏览器的第一个请求(Get方法)已经发布了一个我无法通过http请求复制的cookie。之后,运行Fiddler我看到当我通过浏览器登陆主页时,Request Header是:
GET http://www.somewebsite.com/ HTTP/1.1
Host: www.somewebsite.com
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,el;q=0.8
**Cookie: _asd=sssssss-fffdd-sdd-ffff-sdddffdfd**
复制我的Http请求
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.somewebsite.com/");
request.CookieContainer = new CookieContainer();
request.CookieContainer.Add(cookies);
request.UserAgent = useragent;
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
request.Headers.Add("Accept-Language: en-US,en;q=0.8");
request.Headers.Add("Accept-Encoding: gzip,deflate,sdch");
request.KeepAlive = true;
request.Timeout = 45000;
request.Method = WebRequestMethods.Http.Get;
request.ProtocolVersion = HttpVersion.Version11;
request.AllowAutoRedirect = false;
所以生成的标题是:
GET http://www.somewebsite.com/ HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.8
Accept-Encoding: gzip,deflate,sdch
Referer: http://www.somewebsite.com/
Host: http://www.somewebsite.com/
Connection: Keep-Alive
我缺少什么?感谢