java - Jsoup Login aspx Digikey -


i have problem connect digikey.it jsoup. need login account , use cookies, when execute post, not login. code:

string urllogin="https://www.digikey.it/classic/registereduser/login.aspx?returnurl=%2fclassic%2fregistereduser%2fmydigikey.aspx%3fsite%3dit%26lang%3dit&site=it&lang=it";  connection.response response = jsoup.connect(urllogin)                                     .method(connection.method.get)                                     .execute();  document loginpage = response.parse(); response = jsoup.connect(urllogin)                 .data("ctl00$ctl00$maincontentplaceholder$maincontentplaceholder$txtusername", "username")                 .data("ctl00$ctl00$maincontentplaceholder$maincontentplaceholder$txtpassword", "password")                 .data("ctl00$ctl00$maincontentplaceholder$maincontentplaceholder$btnlogin", "accesso")                 .cookies(response.cookies())                 .method(method.post)                 .followredirects(true)                 .execute() doc = response.parse(); 

who can me?

you can log in code:

try {             string urllogin = "https://www.digikey.it/classic/registereduser/login.aspx?returnurl=%2fclassic%2fregistereduser%2fmydigikey.aspx%3fsite%3dit%26lang%3dit&site=it&lang=it";             connection.response response = jsoup.connect(urllogin)                     .method(connection.method.get)                     .execute();               document loginpage = response.parse();              element eventvalidation = loginpage.select("input[name=__eventvalidation]").first();             element viewstate = loginpage.select("input[name=__viewstate]").first();               response = jsoup.connect(urllogin)                     .data("__viewstate", viewstate.attr("value"))                     .data("__eventvalidation", eventvalidation.attr("value"))                     .data("ctl00$ctl00$maincontentplaceholder$maincontentplaceholder$txtusername", "username")                     .data("ctl00$ctl00$maincontentplaceholder$maincontentplaceholder$txtpassword", "password")                     .data("ctl00$ctl00$maincontentplaceholder$maincontentplaceholder$btnlogin", "accesso")                     .method(connection.method.post)                     .followredirects(true)                     .execute();              document document = response.parse();             element lielement = document.select("li#welcome_name").first();              system.out.println(lielement.html());          } catch (ioexception e) {             e.printstacktrace();         } 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -