利用httpunit获取登陆后的页面、、并且把内容输出来、、、给个例子万分感谢!!!
一直不知道怎么实现登陆
public void postMethod() throws MalformedURLException, IOException, SAXException{
//-----------------------------
System.out.println("使用Post方式向服务器发送数据,然后获取网页内容:");
// 建立一个WebConversation实例
WebConversation wc=new WebConversation();
WebResponse responseLogin;
WebRequest requestLogin;
requestLogin = new PostMethodWebRequest(" http://www.17gude.com/ " );
responseLogin = wc.getResponse(requestLogin);
System.out.println("使用Post方式向服务器发送数据,然后获取网页内容:1");
//WebForm form = responseLogin.getForms()[0]; requestLogin.setParameter("UserLoginName","你舅舅说");
requestLogin.setParameter("UserLoginPass","chenbin"); //此处需要填写真实密码
// requestLogin = form.getRequest();
responseLogin = wc.getResponse(requestLogin);
//assertTrue("转到'zsonline'【suibian】用户首页失败!",responseLogin.getText().indexOf("用户测试用户_zsonline,您好!") != -1);
responseLogin = wc.getCurrentPage();
System.out.println(responseLogin.getText());
}
这样好像登不上去、、、、、、、、、求解决啊 亲!!!!!!!!!!!!!!
一直不知道怎么实现登陆
public void postMethod() throws MalformedURLException, IOException, SAXException{
//-----------------------------
System.out.println("使用Post方式向服务器发送数据,然后获取网页内容:");
// 建立一个WebConversation实例
WebConversation wc=new WebConversation();
WebResponse responseLogin;
WebRequest requestLogin;
requestLogin = new PostMethodWebRequest(" http://www.17gude.com/ " );
responseLogin = wc.getResponse(requestLogin);
System.out.println("使用Post方式向服务器发送数据,然后获取网页内容:1");
//WebForm form = responseLogin.getForms()[0]; requestLogin.setParameter("UserLoginName","你舅舅说");
requestLogin.setParameter("UserLoginPass","chenbin"); //此处需要填写真实密码
// requestLogin = form.getRequest();
responseLogin = wc.getResponse(requestLogin);
//assertTrue("转到'zsonline'【suibian】用户首页失败!",responseLogin.getText().indexOf("用户测试用户_zsonline,您好!") != -1);
responseLogin = wc.getCurrentPage();
System.out.println(responseLogin.getText());
}
这样好像登不上去、、、、、、、、、求解决啊 亲!!!!!!!!!!!!!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货