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

标签 java javascript submit httprequest

我得到了以下场景: 在我的网络服务器上,我有一个 .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/

相关文章:

java内存选项

javascript - 在打开的窗口中从 angularJS 捕获 url

javascript - 获取特殊字符后没有单词的句子

jquery - 使用 jquery 提交 HTML 表单

html - 如何摆脱 input.submit 的背景?

function - Codeigniter:3 个提交按钮,一个功能?

java - 你如何列出网络上的所有 smb 服务器?

Java - 获取目录中的最新文件?

java - 如何在 Javafx 中使用 Arraylist 填充表列

javascript - 页面更改未保存(在页面重新加载时)