Skip to content Skip to sidebar Skip to footer

Login A Website With Jsoup Post Method

I'm trying to login into a website with JSoup post method. I saw some examples but neither are working to me. I'm trying to login to: http://ug.technion.ac.il/Tadpis.html For that

Solution 1:

The url that you see in the address bar is not the one that you want to make the request to. You should make the request to the second url that you see in the form.

//With this you login and a session is createdConnection.Response res = Jsoup.connect("http://techmvs.technion.ac.il:80/cics/wmn/wmngrad?aapmlkwi&ORD=1&s=1")
        .data("username", "myUsername", "password", "myPassword")
        .method(Method.POST)
        .execute();

//This will get you cookiesMap<String, String> loginCookies = res.cookies();

//Here you parse the page that you want. Put the url that you see when you have logged inDocument doc = Jsoup.connect("urlYouNeedToBeLoggedInToAccess")
      .cookies(loginCookies)
      .get();

P.S. I believe that http://techmvs.technion.ac.il:80/cics/wmn/wmngrad is enough. You don't need the extra GET parameters, but check it for yourself.

Post a Comment for "Login A Website With Jsoup Post Method"