当您登录该站点时,可能会设置一个授权会话cookie,需要在后续请求中发送以维护会话。
您可以像这样获取cookie:Connection.Response res = Jsoup.connect("http://www.example.com/login.php")
.data("username", "myUsername", "password", "myPassword")
.method(Method.POST)
.execute();Document doc = res.parse();String sessionId = res.cookie("SESSIONID"); // you will need to check what the right cookie name is
然后在下一个请求发送它,如:Document doc2 = Jsoup.connect("http://www.example.com/otherPage")
.cookie("SESSIONID", sessionId)
.get();