login to vbulletin forums using htmlunit

旧时模样 提交于 2019-12-11 23:45:36

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!