0

my Boss told me to write a HTML parser which is fetching some table datas.... well, I´m stuck here and there and really need your help :)

First of all, I need to login to the website, and then navigate to another url ( I hope that it will work with cookies) and fetching the datas.

The Loginform got the Username & Password field and a selection list with a lot of options, I like to choose the second option..how I can do this?

Here are my code I already got:

 System.setProperty("javax.net.ssl.trustStore", "C:\\unicert.jks");
 Response res = Jsoup.connect("URL to Loginform")
                    .data("u", "UsernameHere")
                    .data("p", "PasswortHere")
                    .data("r", "Second Option")
                    .method(Method.POST).execute();

Map<String, String> loginCookies = res.cookies(); //Getting the Cookies
Document doc2 = Jsoup.connect(url).cookies(loginCookies).get(); //loading new Site with Cookies

I would love to here from you :) thanks a lot! Alex

wikki
  • 35
  • 2
  • 7
  • If I were you, I would connect, login and navigate to proper resource using Apache HTTP Client, and later on parse retrieved HTML with Jsoup using `Jsoup.parse(String html)`. At least I always do such things that way in my workplace. – Antoniossss Sep 17 '13 at 12:02
  • Check this http://stackoverflow.com/questions/6432970/jsoup-posting-and-cookie. As for the second option, as the key, you will put the name of the input, and value, the value of the input. Just inspect the element with firebug (or such). – Alkis Kalogeris Sep 17 '13 at 14:36
  • thanks a lot, could you give me please a example? I dont get it what you mean with inspecting the element? – wikki Sep 17 '13 at 18:36

0 Answers0