每次我尝试登录时,都会返回相同的登录页面,如果我在连接的任何地方出错,请指导我。
注意:我的登录按钮是输入类型图像,它没有值属性
String userAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0";
String username = "username";
String password = "password";
String url = "https://www.ipointweb.net/Secure/Login.aspx";
Connection.Response loginForm = Jsoup.connect(url).timeout(0)
.method(Connection.Method.GET)
.execute();
Document loginPage = loginForm.parse();
Document doc=null;
Connection.Response mainPage = Jsoup.connect(url).timeout(0)
.data("ctl00$ContentPlaceHolder1$Login$UserName",username)
.data("ctl00$ContentPlaceHolder1$Login$Password",password)
.data("ctl00$ContentPlaceHolder1$Login$LoginButton", "")
.data("ctl00_RadStyleSheetManager1_TSSM",loginPage.getElementById("ctl00_RadStyleSheetManager1_TSSM").val())
.data("__EVENTTARGET", "")
.data("__EVENTARGUMENT","")
.data("__VIEWSTATE", loginPage.getElementById("__VIEWSTATE").val())
.data("__VIEWSTATEGENERATOR", loginPage.getElementById("__VIEWSTATEGENERATOR").val())
.data("__EVENTVALIDATION", loginPage.getElementById("__EVENTVALIDATION").val())
.userAgent(userAgent)
.followRedirects(true)
.cookies(loginForm.cookies())
.method(Connection.Method.POST)
.execute();
System.out.println(mainPage.parse().text());
Map<String, String> cookies = mainPage.cookies();
Document evaluationPage = Jsoup.connect("https://www.ipointweb.net/secure/authorised/secAgency/Home.aspx").timeout(0)
.cookies(cookies).execute().parse();
System.out.println(evaluationPage.text());