1

I am trying to do a login in www.forocoches.com and get the cookies for next transactions but its impossible! :/

I am using this code for get the cookie

    Connection.Response res = null;
    String url = "http://www.forocoches.com/foro/forumdisplay.php?f=2";
    print("Fetching %s...", url);
    Map<String, String> loginCookies = null;
    try {
        res = Jsoup.connect(url)
                .data("cookieexists", "false")
                .userAgent("Mozilla/5.0")
                .timeout(100000)
                .data("vb_login_username", "userlogin")
                .data("vb_login_password", "userpassword")
                .method(Method.POST)
                .execute();

    } catch (IOException e) {

        e.printStackTrace();
    }

    loginCookies = res.cookies();

And i am using this for use the cookies

Document doc2 = Jsoup.connect(url2).userAgent("Mozilla/5.0").timeout(100000).cookies(loginCookies).get();

I think that the problem is when i try to get the cookie because the webpage have different forms and the correct is the one who name "log".

Could you help me?

Thanks!

donorom
  • 11
  • 3
  • Have you checked that login was correct? I see two suspicious things, first you are using a login url that seems incorrect, I think it should be `http://www.forocoches.com/foro/login.php?do=login` and second, the login form seems to have more than the three parameters you passed (vb_login_username, vb_login_password, s, securitytoken, do, vb_login_md5password, vb_login_md5password_utf) I'd suggest you to login to the forum using a browser with developer tools enabled and inspect calls and then trying to replicate the behaviour with jsoup. – fonkap Oct 07 '15 at 15:23
  • In addition to what fonkap wrote, you can look at this http://stackoverflow.com/questions/31871801/problems-submitting-a-login-form-with-jsoup/31877829#31877829, it's the same principal. – TDG Oct 07 '15 at 18:40

0 Answers0