0

我正在尝试使用 http 请求将登录信息复制到网站。我的问题是通过浏览器(Get 方法)向主页发出的第一个请求已经发出了一个我无法通过 http 请求复制的 cookie。之后,运行 Fiddler 我看到当我通过浏览器登陆主页时,请求标头是:

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

我错过了什么?谢谢

4

0 回答 0