I am trying to login to http://www.investabroadproperties.com/ site using following code
Connection.Response loginForm = Jsoup.connect("http://www.investabroadproperties.com/")
.method(Connection.Method.GET)
.execute();
Document document = Jsoup.connect("http://www.investabroadproperties.com/")
.data("ctl00$ctl02$tbEmail", "myemail")
.data("ctl00$ctl02$tbPassword", "mypassword")
.cookies(loginForm.cookies())
.post();
But I am unable to login to this site. By looking into the html source of the site, I see that there are some hidden
fields as shown below but with empty values. Also there is an attribute onsubmit="javascript:return WebForm_OnSubmit();"
, I am not sure how to use it.
I also see this post, but I couldn't understand the logic/code that is given in the accepted answer (may be that one will help).
Can anybody help me out that how can I login to the site?
I am using java and jsoup.
I also tried below code but still no luck
Connection.Response loginForm = Jsoup.connect("http://www.investabroadproperties.com/")
.userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1")
.method(Connection.Method.GET)
.execute();
Document doc = loginForm.parse();
Elements hiddenElems = doc.select("input[type=hidden]");
Map<String, String> nameValue = new HashMap<>();
for(Element elem : hiddenElems) {
nameValue.put(elem.attr("name"), elem.attr("value"));
}
Document document = Jsoup.connect("http://www.investabroadproperties.com/")
.userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1")
.data("ctl00$ctl02$tbEmail", "myValidEmail")
.data("ctl00$ctl02$tbPassword", "myValidPassword")
.data(nameValue)
.cookies(loginForm.cookies())
.post();
The following image was taken from my browser's developer tools. As you can see, you are still missing some values in your request:
You must send all these values to the server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With