In addition to username , password and cookies , the site asks for two additional values ββfor login - VIEWSTATE and EVENTVALIDATION .
You can get them from the response of the first Get request, for example:
Document doc = loginForm.parse(); Element e = doc.select("input[id=__VIEWSTATE]").first(); String viewState = e.attr("value"); e = doc.select("input[id=__EVENTVALIDATION]").first(); String eventValidation = e.attr("value");
And add it after password (order doesn't matter) -
org.jsoup.nodes.Document document = (org.jsoup.nodes.Document) Jsoup.connect("https://www.capitaliq.com/CIQDotNet/Login.aspx/authentication.php").userAgent("Mozilla/5.0") .data("myLogin$myUsername", "MyUsername") .data("myLogin$myPassword, "MyPassword") .data("myLogin$myLoginButton.x", "22") .data("myLogin$myLoginButton.y", "8") .data("__VIEWSTATE", viewState) .data("__EVENTVALIDATION", eventValidation) .cookies(loginForm.cookies()) .post();
I would also add a userAgent field for both requests - some sites check it and send different pages to different clients, so if you want the same response as in your browser, add .userAgent("Mozilla/5.0") to the requests (or any browser that you use).
Edit
The username field is myLogin$myUsername , the password is myLogin$myPassword , and the Post request also contains login button information. I canβt verify this because I do not have a user on this site, but I believe that it will work. Hope this solves your problem.
EDIT 2
To enable the remember me field during login, add this line to the Post request:
.data("myLogin$myEnableAutoLogin", "on")
source share