I'm trying to access some page text that requires me to be logged in first.
The login page is = https://utdirect.utexas.edu/
and my attempt so far is like this,
Response res = Jsoup
.connect("https://utdirect.utexas.edu/") // this is the login page
.header("LOGON", "mySchoolID")
.header("PASSWORDS", "mySchoolIDPassword")
.method(Method.POST)
.execute();
Map<String, String> loginCookies = res.cookies(); // cookies to keep me logged in
// This is the page that required me to be loged in first
Document doc = Jsoup.connect("https://utdirect.utexas.edu/apps/degree/audits/requests/history/")
.cookies(loginCookies).get();
Elements e = doc.getAllElements();
for(Element e1 : e){
Log.i("e.text()" , e.text);
}
The problem is that the one that was printed out is the login page NOT the page that i want.
Any idea what's the solution to this one?
Read the login form before posting. You are missing few parameters. Check them for each loging.
Connection.Response loginForm = Jsoup.connect("https://utdirect.utexas.edu/")
.ignoreContentType(true)
.userAgent("Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0")
.referrer("http://www.google.com")
.timeout(12000)
.followRedirects(true)
.method(Connection.Method.GET)
.execute();
Connection.Response loginFormFilled = Jsoup.connect("https://utdirect.utexas.edu/")
.ignoreContentType(true)
.userAgent("Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0")
.followRedirects(true)
.referrer("https://utdirect.utexas.edu/")
.data("CDT","20140103191944")
.data("NEW_PASSWORD", "")
.data("CONFIRM_NEW_PASSWORD", "")
.data("LOGON", "user")
.data("PASSWORDS", "pass")
.cookies(loginForm.cookies())
.method(Connection.Method.POST)
.execute();
Map<String, String> cookies = loginFormFilled.cookies();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With