1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
String baseUrl = "http://www.geny.com/" ;
String baseUrl1 = "http://www.geny.com/reunions-courses-pmu/" ;
String login = "monlogin";
String memoriser = "true";
String password = "monpassword";
String submit = "Ok";
String urlRedirection = "http/www.geny.com/reunions-courses-pmu";
String userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0";
Response res;
res = Jsoup.connect(baseUrl)
.userAgent(userAgent)
.method(Method.GET)
.timeout(10000)
.execute();
String sessionID = res.cookie("JSESSIONID");
Document doc = Jsoup.connect(baseUrl)
.userAgent(userAgent)
.encoding();
.data("urlRedirection", urlRedirection, "login", login, "password", password, "submit", submit, "memoriser",memoriser)
.cookies(res.cookies())
.method(Method.POST)
.timeout(10000)
.get();// now you have filled Session Name with your login info and you can use it for any page in website
doc = Jsoup.connect(baseUrl1)
.userAgent(userAgent)
.cookies(res.cookies())
.timeout(10000)
.get();// her to open any page with Session
Elements links = doc.getElementsByTag("a");
for (Element link : links) {
String linkHref = link.attr("href");
System.out.println(linkHref);
String linkText = link.text();
System.out.println(linkText);
} |
Partager