从选项/选择网络表单下载数据
假设有一个网站,有一系列分层的选项/选择下拉菜单。当用户从下拉列表 A 中进行选择时,其选择的值将发布到服务器并填充下拉列表 B。下拉菜单 B 以相同的方式填充下拉菜单 C。当选择下拉菜单 C 时,将显示特定于他们在 C 中选择的数据。以前的选择会一直保留,除非他们更改了更高的内容,在这种情况下,所有内容都会重置为低于该值。在 HTML 中,它看起来像这样:
Drop-Down A
<select class="submitOnChange">
<option value="a1">A</option>
<option value="a2" SELECTED>B</option>
<option value="a3">C</option>
</select>
Drop-Down B
<select class="submitOnChange">
<option value="b1" SELECTED>B-A</option>
<option value="b2">B-B</option>
<option value="b3">B-C</option>
</select>
Drop-Down C
<select class="submitOnChange">
<option value="c1">B-A-A</option>
<option value="c2">B-A-B</option>
<option value="c3" SELECTED>B-A-C</option>
</select>
[Data for B-A-C is shown here because they clicked that]
该脚本的具体工作方式是,每次选择更改时都会向自身发送所有选定选项的 POST。
我想从这个网络应用程序下载所有数据;也就是说,我想查看与所有可能的下拉 C 值相关的数据。最好的方法是什么?我看到 wget 设置为递归地使用链接,但似乎不适用于这样的表单。我对最简单、最快的方法感兴趣。我了解 PHP,所以我愿意在 cURL 中编写脚本,但是如果有一个更简单的解决方案,例如已经可以完成此操作的程序(wget?),我会很感兴趣。欢迎任何提示或建议。
Suppose there is a website that has a hierarchical series of option/select drop-downs. When the user makes a selection from drop-down A, the value of their selections is posted to the server and drop-down B is populated. Drop-down B populates drop-down C in the same fashion. When drop-down C is selected, data is shown particular to their selection in C. Previous selections are preserved along the way, unless they change something higher up in which case everything is reset below that. In HTML it looks like this:
Drop-Down A
<select class="submitOnChange">
<option value="a1">A</option>
<option value="a2" SELECTED>B</option>
<option value="a3">C</option>
</select>
Drop-Down B
<select class="submitOnChange">
<option value="b1" SELECTED>B-A</option>
<option value="b2">B-B</option>
<option value="b3">B-C</option>
</select>
Drop-Down C
<select class="submitOnChange">
<option value="c1">B-A-A</option>
<option value="c2">B-A-B</option>
<option value="c3" SELECTED>B-A-C</option>
</select>
[Data for B-A-C is shown here because they clicked that]
The script works specifically by sending a POST of all the selected options to itself every time a select changes.
I would like to download all of the data from this web application; that is to say I would like to see the data associated with all possible drop-down C values. What would be the best way to do that? I see that wget is setup to work recursively with links, but seemingly not with forms like this. I'd be interested in the simplest and fastest way for doing this. I know PHP so I'd be open to writing up a script in cURL, however if there's a simpler solution such as a program out there that does this simply already (wget?) I'd be interested. Any tips or suggestions welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 CURL 来做到这一点。
您可以从命令行使用它:
来源是 CURL 手册:http://curl.haxx.se /docs/manual.html
You may use CURL to do that.
You can use it from command line :
Source is the CURL manual : http://curl.haxx.se/docs/manual.html
您可以拥有类似于链接列表的信息结构,其中包含数据和父主键。这样您就可以一次性下载所有数据(例如 JSON)。
我们所做的是设置三个 Web 方法,第一个提供所有设置 A 选项,第二个和第三个采用一个和两个参数,所有三个方法都向客户端提供 JSON,由 JQuery 和 ajax 调用使用:
在本例中,成功函数填充下一个选择,但您可以按照您希望的方式重新格式化数据。 J 包含数据。
You could have information structured like a linked list, where you have the data, and the parent primary key. That way you could download all the data in one shot as JSON for example.
What we did was setup three web methods, the first offering all set A options, the second and third taking one and two parameters, all three offering JSON down to the client, consumed with JQuery and an ajax call:
In this case, the success function populates the next select, but you could reformat the data in anyway you wish. J contains the data.
babonk,
我认为你无法使用该 html 文件将数据发布到服务器,因为你错过了选择部分中的“name”属性,它们应该如下所示:
然后你可以使用以下内容获取内容以下 wget 命令列表:
babonk,
I think you couldn't post the data to your server with that html file, because you've missed the "name" attribute in the select section, they should be like the following:
And then you could get the content with the following wget commands list: