使用 Python 从 ASP 表单下载文件

发布于 2024-10-10 01:08:42 字数 311 浏览 0 评论 0原文

我正在尝试从 http://www.sl.universalservice 下载大量文件.org/funding/opendatasearch/Search1.asp 使用 Python 库 mechanize。在网站上,用户必须填写 2 个 ASP 表单,然后当用户单击第二个提交按钮时,就会开始文件下载。我能够让 Python 程序通过这两种形式,但我不知道如何获取该文件。提交第二份表格后如何访问该文件?

I am attempting to download a lot of files from http://www.sl.universalservice.org/funding/opendatasearch/Search1.asp using the Python library mechanize. On the site, the user must fill out 2 ASP forms, and then when the user clicks the second submit button, a file download starts. I was able to get the Python program to go through both forms, but I do not see how to get the file. How can I access the file once I submit the second form?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅语花开 2024-10-17 01:08:42

使用 b 作为浏览器对象:

b.submit()  # The second of the two forms
c = csv.DictReader(b.response(), dialect='excel-tab')

b.response() 使您可以访问类似文件的对象,该对象可以由 csv 模块处理。

With b as your browser object:

b.submit()  # The second of the two forms
c = csv.DictReader(b.response(), dialect='excel-tab')

b.response() gives you access to a file-like object, which can be processed by the csv module.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文