【发布时间】:2018-12-10 09:32:08
【问题描述】:
我想从未指定文件名的 url 下载文件。如果我在浏览器中输入这个 url (https://www.cpr.dk/vejregister),它会下载正确的文件。
如果我编写此代码,则只下载标头:
# In R
download.file(url = "https://www.cpr.dk/vejregister",
destfile = "/data/kkgrunddata/Vejdata/vejdata_latest",
method='curl')
# In BASH
>more vejdata_latest
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="/media/21570/vejregister_hele_landet_pr_181201.zip">here</a>.</h2>
</body></html>
您对如何在不从标题中指定文件名的情况下下载文件有任何建议吗?
【问题讨论】:
-
我的猜测是某些 javascript(或其他语言?)正在接受您的点击,然后将文件传递给下载。如果是这种情况,您可以使用例如phantomjs在网页上执行javascript并获取文件?