使用download.file同时下载

自从3.2.1版本以来,官方的R文件表示支持同时下载。 以下是帮助文件中的引用文本:

对“libcurl”方法的支持是可选的:使用功能(“libcurl”)来查看它是否受到构建支持。 它提供(非阻塞)访问https://和ftps:// URL。 支持同时下载,因此url和destfile可以是大于1的相同长度的字符向量。 对于单个URL和quiet = FALSE,交互式使用会显示进度条。

但是当我试图从两个不同的网站下载两个文件时,它只下载了一个:

url_list<-c("http://cran.r-project.org/doc/manuals/r-patched/R-exts.html","http://cran.r-project.org/doc/manuals/r-patched/NEWS.pdf")
dest_list<-c("test1.html","test2.pdf")
download.file(url_list,dest_list)

trying URL 'http://cran.r-project.org/doc/manuals/r-patched/R-exts.html'
Content type 'text/html' length 874175 bytes (853 KB)
downloaded 853 KB

Warning messages:
1: In download.file(url_list, dest_list) :
  only first element of 'url' argument used
2: In download.file(url_list, dest_list) :
  only first element of 'destfile' argument used

然后,我看到我错过了使用参数method="libcurl"

download.file(url_list,dest_list,method="libcurl"). 

一旦我在RStudio中运行此命令:R Studio发出致命警告,R会话中止。 使用R for Windows GUI时,会发生以下警告(然后关闭):

R for Windows GUI前端已停止工作。 “一个问题导致程序无法正常工作,Windows将关闭程序并通知您是否有解决方案。”

我正在使用Windows 8.0。 我也运行capabilities("libcurl") ,它提供了以下输出。

libcurl 
   TRUE

根据@thelatemail的评论:设置quiet=TRUE会给出所需的结果(这意味着它是由于进度条导致的):

download.file(url_list,dest_list,method="libcurl",quiet=TRUE)
链接地址: http://www.djcxy.com/p/27215.html

上一篇: simultaneous download using download.file

下一篇: How to disable and enable a image?