经过几个小时的搜索,我仍然不太清楚如何在登录后访问HTML页面。查看这里的各种其他帖子以及Jsoup API,我了解到访问登录后的页面将需要像这样的代码:
Connection.Response loginForm = Jsoup.connect("https://parentviewer.pisd.edu/")
.method(Connection.Method.GET)
.execute();
Document document = Jsoup.connect("https://parentviewer.pisd.edu/")
.data("username", "testUser")
.data("password", "testPass")
.data("LoginButton", "Login")
.cookies(loginForm.cookies())
.post();
不过,我认为我的理解可能有些偏差,因为我仍然不太明确每个值应该填写什么。
例如,在网站上,我会使用input name="ctl00$ContentPlaceHolder1$portalLogin$UserName"作为键,"testUser"作为值吗?
我处理这个任务的方法正确吗? 非常感谢您的帮助。