我正在尝试使用 htmlunit 登录 vbulletins 论坛
我可以连接到我的论坛并设置我的用户名和密码,但是当单击登录按钮时,我无法登录我的用户
这是我的代码:
try{
final WebClient webClient = new WebClient();
webClient.getOptions().setJavaScriptEnabled(false);
webClient.getOptions().setCssEnabled(false);
final HtmlPage page1 =(HtmlPage) webClient.getPage("http://mysite.com/forum.php");
final HtmlForm form1 = (HtmlForm) page1.getElementById("navbar_loginform");
final HtmlSubmitInput button= form1.getInputByValue("login");
final HtmlTextInput username = form1.getElementById("navbar_username");
final HtmlTextInput password = form1.getElementById("navbar_password_hint");
username.setValueAttribute(txtusername.getText());
password.setValueAttribute(String.valueOf(txtpasswd.getPassword()));
final HtmlPage page2 =button.click();
webClient.closeAllWindows();
}
catch(Exception x)
{
JOptionPane.showMessageDialog(null, "can not connect");
}
当我得到 page2 结果的 url 就像“http://mysite.com/login.php?s=36401731df153421f06a8497b3b859df&do=login”
请帮我解决我的问题,谢谢