我正在尝试使用htmlunit登录vbulletin论坛
我可以连接到我的论坛并设置我的用户名和密码,但是当点击登录按钮时,我无法登录到我的用户
这是我的代码:
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");
}
当我得到url的page2结果是这样的"http://mysite.com/login.php?s=36401731df153421f06a8497b3b859df&做=登录"
请帮我解决我的问题,谢谢
我在下面的标签中设置了这些值,我可以登录到我的用户:
input type="hidden" name="vb_login_md5password"
input type="hidden" name="vb_login_md5password_utf"