0
我試圖在Java中與Jsoup自動化SPOJ登錄,但響應頁面是不是我所期待,下面是代碼SPOJ登錄在Java中
public static void login() {
try {
Document doc;
Connection.Response response;
Map<String, String> cookies = new HashMap<>(), form = new HashMap<>();
response = Jsoup.connect(LOGIN_URL) // http://spoj.com/login
.method(Connection.Method.GET)
.userAgent(USER_AGENT)
.execute();
cookies.putAll(response.cookies());
form.put("login_user", LOGIN_ACCOUNT);
form.put("password", LOGIN_PASSWORD);
form.put("next_raw", "/");
response = Jsoup.connect(LOGIN_URL)
.cookies(cookies)
.method(Connection.Method.POST)
.data(form)
.userAgent(USER_AGENT)
.execute();
System.out.println(response.body());
} catch (IOException e) {
}
}
響應體結果仍包含登錄表單,這意味着我的登錄嘗試失敗。任何人都可以幫忙嗎?