使用 Jsoup 的简单例份验证 POST 请求

下面演示了一个带有身份验证数据的简单 POST 请求,请注意 usernamepassword 字段会因网站而异:

final String USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36";
Connection.Response loginResponse = Jsoup.connect("yourWebsite.com/loginUrl")
                                        .userAgent(USER_AGENT)
                                        .data("username", "yourUsername")
                                        .data("password", "yourPassword")
                                        .method(Method.POST)
                                        .execute();