gpt4 book ai didi

java - 使用Jsoup登录pastebin

转载 作者:太空宇宙 更新时间:2023-11-04 07:05:20 24 4
gpt4 key购买 nike

我正在尝试连接到 Pastebin 并登录。当我运行此命令时,HTML 不显示我已登录,并且我的个人资料 ID 不在脚本中的任何位置。

    Response loginResponse;
Document cur = null;
Map<String, String> loginCookies;

loginResponse = Jsoup.connect("http://www.pastebin.com/login.php")
.data("user_name", name)
.data("user_password", pwrd)
.data("submit", "Login")
.method(Method.POST)
.execute();



if (loginResponse != null)
{

loginCookies = loginResponse.cookies();

try
{
cur = Jsoup.connect("http://www.pastebin.com")
.cookies(loginCookies).get();

} catch (Exception e) {
e.printStackTrace();
}

for (Map.Entry<String, String> entry : loginCookies.entrySet())
{
System.out.println(entry.getKey() + "/" + entry.getValue());
}

String s = cur.body().html();
System.out.println(cur.body().html());
System.out.println(cur.body().html().contains("Arhowk"));

}

我相信所有数据字段都是正确的,php 显示正在使用的 POST 方法,应该没问题。我对此还很陌生,我看到很多页面都有答案,但我没有看到任何解决此问题的方法。

最佳答案

尝试像浏览器一样执行此操作;)

  1. 打开页面:

    loginResponse = Jsoup.connect("http://www.pastebin.com/login.php")
    .method(Connection.Method.GET)
    .execute();
  2. 登录

    loginResponse = Jsoup.connect("http://www.pastebin.com/login.php")
    .data("submit_hidden", "submit_hidden")
    .data("user_name", name)
    .data("user_password", pwrd)
    .data("submit", "Login")
    .cookies(loginResponse.cookies()) // pass cookies
    .method(Method.POST)
    .execute();
  3. 结束

关于java - 使用Jsoup登录pastebin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21490138/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com