可以使用 csv 文件在 url 中下载多个 zip 文件吗?

Posted

技术标签:

【中文标题】可以使用 csv 文件在 url 中下载多个 zip 文件吗?【英文标题】:Can a csv file be used to download multiple zip-files in url? 【发布时间】:2020-02-12 22:00:00 【问题描述】:

我有一个包含多个日期的 csv 文件,例如。 Example of dates

我想为 csv 文件中的每个日期下载多个 zip 文件。

在下面的具体示例中,日期为 20151117。有没有办法下载 csv 中的每个日期,可能是通过在下面的代码中包含 csv 文件?

download.file("https://www.quandl.com/api/v3/databases/OSMV/download?download_type=20151117&api_key=my_api_key", destfile = "/Users/anders/Documents/Juni 2019/DATA/datatest.zip", mode="wb", method="libcurl")

我希望我的问题有意义。

谢谢

【问题讨论】:

【参考方案1】:

这是一个应该可以工作的小循环:

df <- data.frame(all_dates = c("20150711","20160613")) 
dates <- unique(df$all_dates) # create list of dates that you want

for (d in dates) # each 'd' is one date

# create url to download from for each date
download.file(paste0("https://www.quandl.com/api/v3/databases/OSMV/download?download_type=", d, "&api_key=my_api_key", 

# create destination file with date in the file name
destfile = paste0("/Users/anders/Documents/Juni 2019/DATA/datatest", d, ".zip", 
mode="wb", method="libcurl"))

【讨论】:

你好佐伊。谢谢您的回答。它就像我所希望的那样工作:)

以上是关于可以使用 csv 文件在 url 中下载多个 zip 文件吗?的主要内容,如果未能解决你的问题,请参考以下文章

从url下载图像并从csv文件中为其指定id

在R中下载csv文件

使用 Beautifulsoup 和 Python 从 CSV 中抓取多个 URL

以 csv 格式下载包含来自多个模型的数据的 zip 文件

从 Cloud Storage 存储分区下载多个文件

如何在 firebase 存储上上传多个文件并将访问 url 和元数据作为 json 或 csv 文件获取? [关闭]