I\'m trying to log into this website: http://deeproute.com
This is my code.
Connection.Response res = null;
Connection homeCo
You need to read form before posting! You are missing param subbera=Login.
public static void main(String[] args) throws Exception {
Connection.Response loginForm = Jsoup.connect("http://deeproute.com/deeproute/default.asp")
.method(Connection.Method.GET)
.execute();
Document document = Jsoup.connect("http://deeproute.com/deeproute/default.asp")
.data("cookieexists", "false")
.data("name", "username")
.data("password", "pass")
.data("subbera", "Login")
.cookies(loginForm.cookies())
.post();
}
Might be a few(many actually) months too late but i found that i had to do some web scrapping where the site was designed really confusing (the site i needed to extract data from). Also had to login first to get cookie info. @MariuszS's answer was helpful but the only problem was, i wasn't sure what the expected Map/Key-Value-Pairs were supposed to be. Thanks to Javascript, i quickly retrieved the form keys and values and was able to login successfully. Here's the Javascript:
var str = "";
//the form selector i.e.
//that which is to be submitted to. In
//my case, i needed to submit the entire body
var arr = $("input[name]");
for(var i = 0, l = arr.length; i<l; i++){
str+= '.data("'+ arr[i].name +'", "'+ arr[i].value +'")'
}
Append the value of "str" to your Jsoup request before
.method(Connection.Method.GET)
.execute();
Hope this proves to be somewhat helpful like it was for me :)