我正在尝试使用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”
请帮我解决我的问题,谢谢
答案 0 :(得分:0)
我在下面的标签中设置了这些值,我可以登录我的用户:
input type="hidden" name="vb_login_md5password"
input type="hidden" name="vb_login_md5password_utf"