简体   繁体   中英

Login on a website via Jsoup

I would like some help for my project. I need to get informations on a forum (medical questions) http://www.safeboy.net/club/index.php? .

But I have a problem, for those informations, I need to be connected on the forum.

But I'm new in Jsoup and I didn't know well Jsoup, so I'm here to have some help, if you could advice me it'll be nice !

Connection.Response loginForm = Jsoup //
            .connect("http://www.safeboy.net/club/club.php?") //
            .method(Method.GET) //
            .execute();

Document document = Jsoup.connect("http://www.safeboy.net/club/club.php?")
                    .data("pseudo", "EDDFSB")
                    .data("password", "cacapopo1").method(Method.POST)
                    .cookies(loginForm.cookies())
                    .post();

    System.out.println(document);

You are missing the call to followRedirect() . After the POST the server sends a redirect to the client (HTTP 302 code).

Document document = Jsoup //
        .connect("http://www.safeboy.net/club/club.php?") //
        .data("pseudo", "EDDFSB") //
        .data("password", "cacapopo1") //
        .method(Method.POST) //
        .cookies(loginForm.cookies()) //
        .followRedirects(true) //
        .post();

The member zone is organized with a frameset. You'll have to ask Jsoup to download each frame of frameset before getting information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM