问题描述
我发送完post请求之后获得了<html><head><title>新浪通行证</title><metahttp-equiv="Content-Type"content="text/html;charset=GBK"/><scriptcharset="utf-8"src="http://i.sso.sina.com.cn/js/ssologin.js"></script></head><body>正在登录...<script>try{sinaSSOController.setCrossDomainUrlList({"retcode":0,"arrURL":["http://crosdom.weicaifu.com/sso/crosdom?action=login&savestate=1451028906"]});}catch(e){}try{sinaSSOController.crossDomainAction('login',function(){location.replace('http://passport.weibo.com/wbsso/login?ssosavestate=1451028906&url=http%3A%2F%2Fweibo.com%2Fajaxlogin.php%3Fframelogin%3D1%26callback%3Dparent.sinaSSOController.feedBackUrlCallBack&ticket=ST-MjY5MzM4NTM3Nw==-1419492906-xd-5087E4B468F34EFC69E7CA5B92426A58&retcode=0');});}catch(e){}</script></body></html>然后截取其中的location.replace里的url进行get请求,返回的内容为空,然后再get请求访问我的新浪微博主页的时候,返回的是SinaVisitorSystem,没有成功登陆,谁能帮我解答下为什么啊?这部分的代码如下://第三次访问GetMethodLogined=newGetMethod(jsonBody1);Logined.getParams().setParameter("http.protocol.cookie-policy",CookiePolicy.BROWSER_COMPATIBILITY);client.executeMethod(Logined);System.out.println(Logined.getStatusLine());Cookie[]cookies=client.getState().getCookies();for(inti=0;i<cookies.length;i++){System.out.println("cookies["+i+"]"+cookies[i]);}//第四次直接访问个人主页Stringhomepage="http://weibo.com/u/2693385377/home?wvr=5&lf=reg";GetMethodhome=newGetMethod(homepage);home.setRequestHeader("Accept","text/html,application/xhtml+xml,application/xml;");home.setRequestHeader("Accept-Language","zh-cn");home.setRequestHeader("User-Agent","Mozilla/5.0(Windows;U;WindowsNT5.1;zh-CN;rv:1.9.0.3)Gecko/2008092417Firefox/3.0.3");home.setRequestHeader("Accept-Charset","UTF-8");home.setRequestHeader("Keep-Alive","300");home.setRequestHeader("Connection","Keep-Alive");home.setRequestHeader("Cache-Control","no-cache");home.setRequestHeader("Cookie",cookies.toString());client.getState().addCookies(cookies);home.getParams().setParameter("http.protocol.cookie-policy",CookiePolicy.BROWSER_COMPATIBILITY);client.executeMethod(home);//System.out.println(home.getStatusLine());InputStreamis3=home.getResponseBodyAsStream();System.out.println(is3);Stringresponse3=inputStreamToString(is3,null);System.out.println(response3);home.releaseConnection();