gpt4 book ai didi

java - 使用 Java 登录 vbulletin 论坛

转载 作者:太空宇宙 更新时间:2023-11-04 08:51:31 25 4
gpt4 key购买 nike

作为我论文论文的一部分,我构建了一个“机器人”,它会抓取 C 语言编程类(class)的官方论坛并搜索常见问题以便发布回复。我现在必须模拟登录才能发布适当的回复。登录表单如下:

!-- 登录表单 -- 表单操作=“login.php?do=login”方法=“post”onsubmit=“md5hash(vb_login_password,vb_login_md5password,vb_login_md5password_utf,0)”> 脚本类型=“text/javascript”src=“clientscript/vbulletin_md5.js?v=385”> 表 cellpadding="0"cellspacing="3"border="0"> TR> td class="smallfont"style="white-space: nowrap;">Όνομα χρήστη TD>

td class="smallfont"nowrap="nowrap">Aυτόματη Σύνδεση /tr> TR> td class="smallfont">Kωδικός TD> TD> /tr> /表>

输入类型=“隐藏”名称=“s”值=“”/> 输入类型=“隐藏”名称=“安全 token ”值=“访客”/> 输入类型=“隐藏”名称=“do”值=“登录”/> 输入类型=“隐藏”名称=“vb_login_md5password”/> 输入类型=“隐藏”名称=“vb_login_md5password_utf”/> /表格> !--/登录表单 -->

我开始明白我需要对密码进行 md5 哈希处理,但我无法登录。我使用 post 方法并执行以下操作准备内容:

content = "do=login&url=login.php" + "&vb_login_md5password=" + md5_pass+ "&vb_login_md5password_utf="+ md5_pass + "&s=&securitytoken=guest&vb_login_username=" + UserName + "&vb_login_password=" + PassWprd;

然后,我通过执行以下操作来发送内容:

urlConnection = (HttpURLConnection)(new URL(targetUrl).openConnection());

// Specifying that we intend to use this connection for input
urlConnection.setDoInput(true);

// Specifying that we intend to use this connection for output
urlConnection.setDoOutput(true);

// Specifying the method of HTTP request which is POST
// throws ProtocolException
urlConnection.setRequestMethod("POST");

// Specifying the content type of our post
urlConnection.setRequestProperty("Content-Type", POST_CONTENT_TYPE);
urlConnection.setRequestProperty("Content-length",String.valueOf (content.length()));
// urlConnection.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)");

// Prepare an output stream for writing data to the HTTP connection
// throws IOException
dataOutputStream = new DataOutputStream(urlConnection.getOutputStream());
dataOutputStream.writeBytes(content);

尽管如此,我还是无法登录。我相信我发送的表格有问题,但我找不到问题所在。任何帮助将不胜感激,因为我必须在几天内完成该计划。

最佳答案

我建议您不要尝试手动伪造 HTTP 请求,而是依赖虚拟 Web 客户端,例如 HtmlUnit 。它允许您进入更高的级别,并且您不必尝试使用正确的元素伪造 HTTP 查询,而只需“简单”地使用正确的值填写表单即可。

关于java - 使用 Java 登录 vbulletin 论坛,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3237410/

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