This is my current code, I've being seeking for answers all over the internet and nothing worked for me. The link of the website that I've been trying to scrape is :
After the login this is webpage that I should get :
The issue I have is no matter what i try with the JSESSION cookie without forgeting to add all .data input values, I still cannot successfully login and get the redirected page as shown above. Can anybody help me with this ? Thank you !
public static void main(String[] args) throws Exception {
try {
Connection.Response loginForm = Jsoup.connect(loginFormUrl)
.method(Connection.Method.GET)
.userAgent(userAgent)
.execute();
Map<String, String> mapLoginPageCookies = loginForm.cookies();
//System.out.println(sessionID);
Connection.Response login = Jsoup.connect(loginFormUrl)
.cookies(mapLoginPageCookies)
.data("login", "lecteur1")
.data("password", "")
.userAgent(userAgent)
.followRedirects(true)
.method(Connection.Method.POST)
.execute();
System.out.println("HTTP Status Code: " login.statusCode());
Document page = Jsoup.connect("https://planif.esiee.fr/jsp/standard/projects.jsp")
.cookies(login.cookies())
.get();
System.out.println(page);
} catch (IOException e) {
e.printStackTrace();
}
}
CodePudding user response:
You submit your data to loginFormUrl
Connection.Response login = Jsoup.connect(loginFormUrl)
but in the page source I see the form should be sent to https://planif.esiee.fr/jsp/standard/gui/interface.jsp
<form method="POST" action="gui/interface.jsp" name="projects">
Try using that URL instead of loginFormUrl
.