gpt4 book ai didi

java - 在 Java 中请求 HTTPS 并提交表单

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

我得到了以下场景:在我的网络服务器上,我有一个 .do 文件,其中包含如下 HTML 代码:

<form name="login" action="someAction" method="post">
//some textboxes
</form>
<input type="submit" value="Submit" />

现在我正在尝试创建一个应用程序,它连接到网络服务器 - https - 填写表单并从下一个站点(您登录时的站点)获取 HTML。之后,我必须执行几次 JavaScript 提交才能获取我想要在桌面应用程序中显示的数据。

我设法建立了一个连接并从登录站点获取了 HTML,但由于我对 HttpRequests 和类似的东西不熟悉,所以我不知道如何继续。

如果有帮助,我们将不胜感激。

编辑:我在控制台中看到以下内容:

Sep 24, 2011 2:23:28 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Obsolete content type encountered: 'text/javascript'.
Sep 24, 2011 2:23:30 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Obsolete content type encountered: 'text/javascript'.
Wrapped com.gargoylesoftware.htmlunit.ScriptException: Error: ERROR: No matching script interactive for function () {
var result = bootstrapDojo();
result.dojo._dijit = result.dijit;
result.dojo._dojox = result.dojox;
return result.dojo;
}

最佳答案

我建议您使用htmlunit :

HtmlUnit is a "GUI-Less browser for Java programs". It models HTML documents and provides an API that allows you to invoke pages, fill out forms, click links, etc... just like you do in your "normal" browser.

It has fairly good JavaScript support (which is constantly improving) and is able to work even with quite complex AJAX libraries, simulating either Firefox or Internet Explorer depending on the configuration you want to use.

It is typically used for testing purposes or to retrieve information from web sites.

关于java - 在 Java 中请求 HTTPS 并提交表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7536022/

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