且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Jsoup的Android登录网站

更新时间:2023-12-03 21:18:22

您可以检查以下几点:

尝试使用您喜欢的浏览器手动登录,并使用开发工具栏或 Fiddler 之类的工具监视其交换. >.完成后,使用Jsoup在代码中重现相同的交换.

Try to login manually with your favorite browser and spy its exchanges with the Dev Toolbar or a tool like Fiddler. Once done, reproduce the same exchanges in your code with Jsoup.

确保服务器不会随机生成这些字段.您可能需要从文档中提取它们的值,而不用硬编码它们各自的值.

Ensure these fields aren't generated randomly by the server. You may need to extract their value from the document and not hard code their respective values.

请参见以下两行:

.data("form_key", "WrToMuENMoOq8ZA3") // randomly generated ?
.data("form_key_test", "WrToMuENMoOq8ZA3") // randomly generated ?

3)缺少Cookie

您是否检查了以下语句是否不会产生以后获取https://www.cgv.vn/vn/customer/account/所需的新cookie.

3) Missing cookies

Did you check that the following statements doesn't produce new cookies needed for later fetching https://www.cgv.vn/vn/customer/account/.

Document document = Jsoup.connect(urlLogin)
                .data("login[username]", "ABC")
                .data("login[password]", "ABC")
                .data("cookieexists", "false")
                .data("form_key", "WrToMuENMoOq8ZA3")
                .data("form_key_test", "WrToMuENMoOq8ZA3")
                .data("send", "")
                .cookies(loginForm.cookies())
                .post();