Using Jsoup to POST login data

后端 未结 2 1158
死守一世寂寞
死守一世寂寞 2021-01-19 16:12

I\'m trying to log into this website: http://deeproute.com

This is my code.

            Connection.Response res = null;
            Connection homeCo         


        
2条回答
  •  走了就别回头了
    2021-01-19 17:01

    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

    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 :)

提交回复
热议问题