Login to vBulletin using htmlUnit

谁说我不能喝 提交于 2019-12-11 08:56:02

问题


I don't understand what the problem is with this code (ignore the socks proxy btw that's not the issue...) I'm trying to login to my vBulletin form so I can make a script which auto bans people and stuff. But when I run this it can't even find the login form, so I wrote a for loop to list all of the forms on the main page... It only managed to find the shout box, which is not what I want! Anyone have any idea of why it can't find the login form at the top of the page?

public Application() {
    System.setProperty("socksProxyHost", "localhost");
    System.setProperty("socksProxyPort", "9050");
    final WebClient webClient = new WebClient();
    webClient.getOptions().setJavaScriptEnabled(false);
    webClient.getOptions().setCssEnabled(false);
    HtmlPage page;
    try {
        page = webClient.getPage("http://cartoonamon.com/forum.php");
        HtmlForm login = null;
        for (HtmlForm f : page.getForms()) {
            System.out.println(f.getNameAttribute());
        }
//          HtmlTextInput username = login.getElementById("navbar_username");
//          HtmlTextInput password = login.getElementById("navbar_password");
//          HtmlSubmitInput submit = login.getInputByValue("Log in");
//          username.setValueAttribute("nolooking");
//          password.setValueAttribute("nolooking!");
//          HtmlPage page2 = submit.click();
    } catch (FailingHttpStatusCodeException | IOException e) {
        e.printStackTrace();
    }

    webClient.closeAllWindows();
}

来源:https://stackoverflow.com/questions/17957622/login-to-vbulletin-using-htmlunit

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