【问题标题】:Name of a document behind an HTML link?HTML链接后面的文档名称?
【发布时间】:2017-05-26 15:41:02
【问题描述】:

我需要从网页自动下载文档(使用 Python 脚本)。在 HTML 页面中,链接如下所示:

href="https://foo.bar/view.php?id=123456"

当我在 Web 浏览器中单击此类链接时,Web 浏览器会以正确的名称打开文档 - 例如:document_1.pdf

但是,当我使用 wget 下载相同的文档时:

$ wget https://foo.bar/view.php?id=123456

我确实得到了正确的文档,但名称不同:view.php@id=123456

现在,文档的真实名称(本例中为document_1.pdf)在 HTML 页面中没有出现。我怎样才能得到它?

如果 Web 浏览器可以获取文档的名称,那么脚本也必须可以获取,但是如何呢?

【问题讨论】:

  • 文件下载服务器响应包含a header中的文件名。
  • 是的,就是这样。谢谢!

标签: php python html http


【解决方案1】:

在 cmets 中解决:

The file download server response contains the file name in a header. – James

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-10
    • 2011-02-10
    • 2011-11-04
    • 1970-01-01
    相关资源
    最近更新 更多