标签: r-download.file

在 R 中下载多个文件的更快方法

我用 R 编写了一个小型下载器,以便一次运行从远程服务器下载一些日志文件:

file_remote <- fun_to_list_URLs()
file_local <- fun_to_gen_local_paths()
credentials <- "usr/pwd"

downloader <- function(file_remote, file_local, credentials) {
  data_bin <- RCurl::getBinaryURL(
    file_remote,
    userpwd = credentials,
    ftp.use.epsv = FALSE,
    forbid.reuse = TRUE
  )
  
  writeBin(data_bin, file_local)
}
  
purrr::walk2(
  file_remote,
  file_local,
  ~ downloader(
    file_remote = .x,
    file_local = .y,
    credentials = credentials
  )
)
Run Code Online (Sandbox Code Playgroud)

这可行,但速度很慢,尤其是与 WinSCP 等一些 FTP 客户端相比,下载 64 个日志文件,每个 2kb,需要几分钟。

R中有没有更快的方法来下载大量文件?

r rcurl r-download.file

5
推荐指数
1
解决办法
1129
查看次数

标签 统计

r ×1

r-download.file ×1

rcurl ×1