How to POST Data into website using Jsoup
If the issue is a javascript redirect, you could try going into the javascript and checking if the URL it redirects to is static, and then use the redirection to gain access. I did that to access a popup box made by javascript once.
I will give the answer of your question by taking an example. Suppose you want to login to facebook.
Then apart from username and password there are many other parameters that are also passed through POST
request. Those all parameters are hidden and are passed similarly like username and password.
For Example :
If you will open the html source
of facebook , then you can see there is one parameter which is hidden is lgnrnd
and its value is 071129_5D7M
.
So there are many other parameter similar like this.You need to pass all the parameters.
You should also specify the userAgent.
Document doc = Jsoup.connect("http://www.facebook.com")
.data("email", "myemailid")
.data("pass", "mypassword")
// and other hidden fields which are being passed in post request.
.userAgent("Mozilla")
.post();
System.out.println(doc); // will print html source of homepage of facebook.