使用 Python 从 ASP 表单下载文件
我正在尝试从 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 b 作为浏览器对象:
b.response() 使您可以访问类似文件的对象,该对象可以由 csv 模块处理。
With b as your browser object:
b.response() gives you access to a file-like object, which can be processed by the csv module.