java - Using Jsoup to POST login data -
i'm trying log website: http://deeproute.com
this code.
connection.response res = null; connection homeconnection = null; document homepage = null; map<string, string> logincookies = null; try { res = jsoup.connect("http://www.deeproute.com/") .data("cookieexists", "false") .data("name", user) .data("password", pswd).method(method.post) .execute(); } catch (ioexception e) { e.printstacktrace(); } if (res != null) { logincookies = res.cookies(); try { homepage = jsoup.connect("http://www.deeproute.com") .cookies(logincookies).get(); } catch (ioexception e) { e.printstacktrace(); }
unfortunately, returns same page in not-logged-in state. doing wrong?
you need read form before posting! 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(); }
Comments
Post a Comment