java,导入httpClient包postMethod如何向指定网页传入账号密码,并且获得跳转后页面的url?
已经导入httpClient和Htmlparser包,现在要向某网站提交账号密码,模拟登陆功能,请问如何postMethod实现参数传递和使得页面跳转并获得跳转后页面的u...
已经导入httpClient和Htmlparser 包,现在要向某网站提交账号密码,模拟登陆功能,请问如何postMethod实现参数传递和使得页面跳转并获得跳转后页面的url?
展开
3个回答
展开全部
webClient.setJavaScriptEnabled(true);
webClient.setJavaScriptTimeout(3600*1000);
webClient.setRedirectEnabled(true);
webClient.setThrowExceptionOnScriptError(true);
webClient.setThrowExceptionOnFailingStatusCode(true);
webClient.setTimeout(3600*1000);
webClient.waitForBackgroundJavaScript(600*1000);
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
// if (Integer.parseInt(currentPage)<6) {
page = (HtmlPage) webClient.getCurrentWindow().getEnclosedPage();
HtmlAnchor a=(HtmlAnchor)page.getAnchorByText(currentPage);
try {
page=a.click();
Thread.sleep(time);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
page = (HtmlPage) webClient.getCurrentWindow().getEnclosedPage();
webClient.setJavaScriptTimeout(3600*1000);
webClient.setRedirectEnabled(true);
webClient.setThrowExceptionOnScriptError(true);
webClient.setThrowExceptionOnFailingStatusCode(true);
webClient.setTimeout(3600*1000);
webClient.waitForBackgroundJavaScript(600*1000);
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
// if (Integer.parseInt(currentPage)<6) {
page = (HtmlPage) webClient.getCurrentWindow().getEnclosedPage();
HtmlAnchor a=(HtmlAnchor)page.getAnchorByText(currentPage);
try {
page=a.click();
Thread.sleep(time);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
page = (HtmlPage) webClient.getCurrentWindow().getEnclosedPage();
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
//传送数据
String requestData = g.toJson(paramMap);
//接收
String result = HttpClients.doPost(url, requestData);
String requestData = g.toJson(paramMap);
//接收
String result = HttpClients.doPost(url, requestData);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询