各位高人:我想用httpClient模拟登陆后,获取登陆后网页的信息,但是却无论如何也得不到登陆后网页的信息,整了好久也不知道解决,请各位高手知道指教一下.不胜感激.我首先用ieHttpHeaders获取到netyi.net(得益网)的cookie信息如下:
POST /jsLoginStatus.aspx?returnUrl=%2fjsLoginStatus.aspx%3fguid%3db71cdc08-8622-42de-a4ba-fbd395c032ca 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://netyi.net/jsLoginStatus.aspx
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; Maxthon; .NET CLR 2.0.50727)
Host: netyi.net
Content-Length: 53
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: __utma=7615405.1271095282.1176109184.1186976162.1189938905.6; __utmz=7615405.1186977812.5.7.utmccn=(organic)|utmcsr=google|utmctr=spring+in+action+%E4%B8%8B%E8%BD%BD|utmcmd=organic; cnzz02=6; rtime=1; ltime=1190001640890; cnzz_eid=1250906-http%3A//zyjarge.spaces.live.com/blog/cns%21939889bfd1aba233%21497.entry; dnttemplateid=0; ASP.NET_SessionId=0hiqkbiudskwzy45sgrenbme
UserName=zlh218&Password=000000&Submit.x=0&Submit.y=0
HTTP/1.1 302 Found
Date: Mon, 17 Sep 2007 04:00:06 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Location: /jsLoginStatus.aspx?guid=e1579e4a-0a08-48c8-a52f-e8110820dd80
Set-Cookie: Passport=zlh218; domain=.netyi.net; path=/
Set-Cookie: validateCode=88E67E5A0FA31EA4D710A2E00A28C414; domain=.netyi.net; path=/
Set-Cookie: dnt=userid=802856&password=K8UyuJGWSS%2bbJ%2fduDu3plC07d%2fl6D%2b%2bqxIsCtqLlc0oTTWu77t9g3w%3d%3d&tpp=0&ppp=0&pmsound=0&invisible=0&referer=index.aspx&sigstatus=0&expires=-1; path=/
Set-Cookie: dnttemplateid=0; expires=Tue, 11-Aug-2009 14:39:06 GMT; path=/
Set-Cookie: dnt=userid=802856&password=K8UyuJGWSS%2bbJ%2fduDu3plC07d%2fl6D%2b%2bqxIsCtqLlc0oTTWu77t9g3w%3d%3d&tpp=0&ppp=0&pmsound=0&invisible=0&referer=index.aspx&sigstatus=0&expires=-1; path=/
Set-Cookie: lastolupdate=1043693968; path=/
Set-Cookie: .ASPXAUTH=6C2E31EECFB08DFF79EA98EAAB54AB30D2CBA7A5CBEB5609312C30989F56CF07DDB84D281E03DD6AF89B4070918C20D25E0195D8F4AB9193E08AA9B0FCA53B16405AFCFD166DBEC7B30340F46E325669; domain=.netyi.net; path=/; HttpOnly
Cache-Control: private
Content-Type: text/html; charset=gb2312
Content-Length: 178
我的代码如下:
HttpClient client = new HttpClient();
client.getHostConfiguration().setHost( "netyi.net " , 80, "http " );
client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
PostMethod post = new PostMethod( "/jsLoginStatus.aspx?returnUrl=%2fjsLoginStatus.aspx%3fguid%3db71cdc08-8622-42de-a4ba-fbd395c032ca " );
//NameValuePair chk = new NameValuePair( "chk " , "yes " );
//NameValuePair re = new NameValuePair( "re_log " , "yes " );
NameValuePair name = new NameValuePair( "UserName " , "zlh218 " );