问题
i am trying to login vbulletins forum using htmlunit
i can connect to my forum and set my username and password but when click in login button i can not login into my user
this is my code :
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");
}
when i get url of page2 result is like "http://mysite.com/login.php?s=36401731df153421f06a8497b3b859df&do=login"
please help me to fix my problem , thank you
回答1:
I set these values in the below tags and I could login to my user:
input type="hidden" name="vb_login_md5password"
input type="hidden" name="vb_login_md5password_utf"
来源:https://stackoverflow.com/questions/14033257/login-to-vbulletin-forums-using-htmlunit