我想做一个程序模拟登录一网站,但总是出问题,请求和回应数据如下:
第一步(客户端请求):
POST http://www.lanniao.org/soft/nod32/PPst_Login.asp?Action=Login HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer: http://www.lanniao.org/soft/nod32/PPst_Login.asp
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; (R1 1.5); .NET CLR 2.0.50727; .NET CLR 1.1.4322; MAXTHON 2.0)
Host: www.lanniao.org
Content-Length: 51
Proxy-Connection: Keep-Alive
Pragma: no-cache
Cookie: rtime=3; ltime=1179899260484; cnzz_eid=89202487-; cnzz02=4; ASPSESSIONIDQCDBSRRA=JGOJIEOBNHCMPHOBPMFMHAPC
Username=myname&Password=mypass&Submit=%CC%E1%BD%BB
第二步(服务端应答):
HTTP/1.1 302 Object moved
Date: Wed, 23 May 2007 05:47:55 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Location: PPst_UserCenter.asp
Content-Length: 140
Content-Type: text/html
Set-Cookie: PPst%5FUserName=myname; path=/
Set-Cookie: PPst%5FLastIP=221%2E3%2E149%2E10; path=/
Set-Cookie: PPst%5FLastTime=2007%2D5%2D23+13%3A42%3A49; path=/
Set-Cookie: PPst%5FLevel=1; path=/
Cache-control: private
第三步(客户端重定向请求):
GET http://www.lanniao.org/soft/nod32/PPst_UserCenter.asp HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer: http://www.lanniao.org/soft/nod32/PPst_Login.asp
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; (R1 1.5); .NET CLR 2.0.50727; .NET CLR 1.1.4322; MAXTHON 2.0)
Host: www.lanniao.org
Proxy-Connection: Keep-Alive
Pragma: no-cache
Cookie: rtime=3; ltime=1179899260484; cnzz_eid=89202487-; cnzz02=4; ASPSESSIONIDQCDBSRRA=JGOJIEOBNHCMPHOBPMFMHAPC; PPst%5FUserName=myname; PPst%5FLastIP=221%2E3%2E149%2E10; PPst%5FLastTime=2007%2D5%2D23+13%3A42%3A49; PPst%5FLevel=1
第四步(服务端应答):
<head> <title> Object moved </title> </head>
<body> <h1> Object Moved </h1> This object may be found <a HREF= "PPst_UserCenter.asp "> here </a> . </body>
HTTP/1.1 200 OK
Cache-Control: private
Date: Wed, 23 May 2007 05:47:58 GMT
Content-Type: text/html
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Content-Encoding: gzip
Vary: Accept-Encoding
Transfer-Encoding: chunked
这几步下来没有想到我的界面,问题是出在哪啊?
------解决方案--------------------
先在浏览器里正常登录PPst_UserCenter.asp,用httpwatch记录下登录过程看看