JSOUP login and parsing -
i need database size value tab. url: http://www.try-phpbb.com/31x/ucp.php?mode=login need logged in twice. failed @ once.
trying no success:
connection.response res = jsoup .connect("http://www.try-phpbb.com/31x/ucp.php?mode=login") .data("username", "administrator") .data("password", "administrator") .method(connection.method.post) .execute();
i guess need more info username , password send along in form. in html of website shows login form contains hidden fields, including input name sid
. seems id generated server, need login page first, read out sid (and maybe session cookies) , send along post request. should trick.
1) login page
2) read cookies, read out sid. network tab in chrome shows site sets following cookies:
phpbb3_ascraeus_90541803_u=1; phpbb3_ascraeus_90541803_k=; phpbb3_ascraeus_90541803_sid=befc4716f8061a422407f4f77207e2a8
in joup can access cookies so:
connection.response res = jsoup.connect("http://www.try-phpbb.com/31x/ucp.php?mode=login") .execute(); string phpbb3_ascraeus_90541803_sid = res.cookie("phpbb3_ascraeus_90541803_sid"); string rawhtml = res.body(); document doc = jsoup.parse(rawhtml); string sid = doc.select("input[name=sid]").first().attr("value");
3) generate post request cookies, username, password , sid form fields. so:
connection.response res = jsoup .connect("http://www.try-phpbb.com/31x/ucp.php?mode=login") .data("username", "administrator") .data("password", "administrator") .data("sid", "sid") .cookie("phpbb3_ascraeus_90541803_sid", phpbb3_ascraeus_90541803_sid) .method(connection.method.post) .execute();
note did not test this. may or may not need cookie. maybe need cookies , hidden inputs. experiment yourself. should enough grasp idea. actual coding job, right?
Comments
Post a Comment