jsoup posting and cookie
When you login to the site, it is probably setting an authorised session cookie that needs to be sent on subsequent requests to maintain the session.
You can get the cookie like this:
Connection.Response res = Jsoup.connect("http://www.example.com/login.php")
.data("username", "myUsername", "password", "myPassword")
.method(Method.POST)
.execute();
Document doc = res.parse();
String sessionId = res.cookie("SESSIONID"); // you will need to check what the right cookie name is
And then send it on the next request like:
Document doc2 = Jsoup.connect("http://www.example.com/otherPage")
.cookie("SESSIONID", sessionId)
.get();
//This will get you the response.
Response res = Jsoup
.connect("loginPageUrl")
.data("loginField", "[email protected]", "passField", "pass1234")
.method(Method.POST)
.execute();
//This will get you cookies
Map<String, String> loginCookies = res.cookies();
//And this is the easiest way I've found to remain in session
Document doc = Jsoup.connect("urlYouNeedToBeLoggedInToAccess")
.cookies(loginCookies)
.get();