求教一个用HttpClient访问管理系统的问题!
各位大侠,先问好。
小弟被这样一个问题困扰,请各位指教。
我想用HttpClient模拟登陆一个信息管理系统抓取一些网络数据。从网上找到了一份开心网的登陆源码,进行相关修改。
访问的MIS系统采用的是Frmae布局。
当我输入用户名,密码以及浏览器信息之后,获得访问session之后,转向到MIS页面的时候,
//登录页面
String LOGON_SITE="http://domain/login";
PostMethod post = new PostMethod(LOGON_SITE);
NameValuePair ie = new NameValuePair("User-Agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows 2000)");
NameValuePair url = new NameValuePair("url", "/home/");
NameValuePair username = new NameValuePair("myid",userName);
NameValuePair password = new NameValuePair("mypsd", passwd);
post.setRequestBody(new NameValuePair[] { ie,url,username, password});
client.executeMethod(post);
System.out.println("******************************登录******************************");
Cookie[] cookies = client.getState().getCookies();
client.getState().addCookies(cookies);
post.releaseConnection();
System.out.println("******************************页面转向******************************");
String newUrl="http://domain/index.jsp";
System.out.println("==========Cookies============");
int i=0;
for(Cookie c:cookies){
System.out.println(++i+": "+c);
}
client.getState().addCookies(cookies);
post.releaseConnection();
GetMethod get = new GetMethod(newUrl);
get.setRequestHeader("Cookie", cookies.toString());
client.executeMethod(get);
String responseString = get.getResponseBodyAsString();
//登录后首页的内容
System.out.println(responseString);
总是获得这样的一段代码
if(top.location!=self.location){
top.location=self.location;
}
window.location.ref="/login";
我想问的是,是不是因为这一段代码进行屏蔽,让我无法取得想访问的index.jsp ?
是否还有其他办法访问index.jsp页面?谢谢各位