Login to website using jsoup in android returning login page instead of home page -


i have used input tags fields name source , tried possible ways using jsoup connect each time output html page showing in log.e same login page.

protected void doinbackground(void... params) {     try {    connection.response loginform = jsoup.connect("http://adsl.yemen.net.ye/en/login.aspx")               //  .useragent("mozilla/5.0 (windows nt 10.0; wow64) applewebkit/537.36 (khtml, gecko) chrome/51.0.2704.103 safari/537.36")                 .method(connection.method.get)                 .execute();         loginform= jsoup.connect("http://adsl.yemen.net.ye/en/login.aspx")                 .data("ctl00$contentplaceholder1$loginframe$username", "masalahi2010")                 .data("ctl00$contentplaceholder1$loginframe$password", "mamam")                // .data("ctl00$contentplaceholder1$loginframe$rememberme","true")                 .data("ctl00$contentplaceholder1$loginframe$loginbutton", "sign in")                 .data("__lastfocus", "")                 .data("__eventtarget", "")                 .data("__eventargument","")                 .data("__viewstate","/wepdwullte4nzkxodyxntipzbyczg9kfgicaw9kfgqcaq9kfgqcaw8pfgieb1zpc2libgvozgqcbq8pfgifaghkzaidd2qwcaibdzwraaobaa8wah4ivxnlck5hbwufde1bu0fmquhjmjaxmgqwamypzbyeagmpdxyghghszwfkt25sewcebfrlehqfde1bu0fmquhjmjaxmb4hrw5hymxlzghkzaipdxapfgieb0nozwnrzwrozgrkzaifdw8wah8aagrkagcpdxychwbozgqccq8pfgifaghkfgicbq8pfgifbghkzbgbbr5fx0nvbnryb2xzumvxdwlyzvbvc3rcywnrs2v5x18waquvy3rsmdakq29udgvudfbsywnlsg9szgvymsrsb2dpbmzyyw1ljfjlbwvtymvytwu9ui0fnjqunhcww2dc7yfhnqtbncjm7q+evewp9rv8yg==")                 .data("__viewstategenerator","ee376e4e")                 .data("__eventvalidation","/wewbqkp+ocbcalfq6j2aqkr/oc4dgkj1+lbcwls5zy/pegu3qyhck5jspkxcvy2hzzwlecsbxeq4tprzkrhv7e=")                 .useragent("mozilla/5.0 (windows nt 10.0; wow64) applewebkit/537.36 (khtml, gecko) chrome/51.0.2704.103 safari/537.36")                 .cookies(loginform.cookies())                    .method(connection.method.post)                 .execute();          document homepage = jsoup.connect("http://adsl.yemen.net.ye/en/user_main.aspx")                 .cookies(loginform.cookies())                 .get();             log.e("test", homepage.html());      } catch (ioexception e) {         e.printstacktrace();     }      return null; } 

you're there, few minor things:

you see login form data need send other username , password (e.g. __viewstate, __eventvalidation , more)? need retrieved dynamically. believe unique values sent when first go login form page.

so need is, instead of posting fixed values, need parse them first loginform received, set cookies first login form.

for more details i've written comprehensive tutorial on how login websites using jsoup here, believe lot.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -