模板代码,复制粘贴就完事了

1
2
3
4
5
6
7
8
9
10
11
12
13
// This will get you the response.
Response res = Jsoup.connect("loginPageUrl")
.data("loginField", "login@login.com", "passField", "pass1234")
.method(Method.POST)
.execute();

// This will get you cookies
Map<String, String> loginCookies = res.cookies();

// And this is the easiest way I've found to remain in session
Document doc = Jsoup.connect("urlYouNeedToBeLoggedInToAccess")
.cookies(loginCookies)
.get();