R语言下载函数download.file与download剖析

一.download.file函数

download.file(url,destfile,method,quiet=FALSE,mode="w",cacheOK=TRUE,extra=getOption("download.file.extra"))
    url:字符串,必须http://,https://,ftp://,file://开头
    destfile:下载文件的保存地址,默认工作目录,file为保存文件名
    method:提供"internal","wget","curl","lynx","libcurl","wininet".windows上通常internal就能解决大多数的问题,少数搞不定的如Cygwin,gnuwin32用"wget",windows二进制文件用"curl".method对于Mac用户来说是都要设置的."lynx"主要针对historical interest
    quiet:TRUE-禁止状态消息,显示进度条
    mode:写入文件模式,只能在method="internal"时使用,"w"/"wb"(binary)/"a"(append)/"ab"
    cacheOK:是否接受服务器端的缓存值,对http://,https://使用.FALSE-尝试从站点获取副本,而不是从中间缓存中获取

注:

1.method="auto"(默认):windows-wininet(只能Windows使用),ftps://urls-libcurl;对于"wget","curl"-相应程序必须安装在系统上,且位于可执行文件的搜索路径中

2.method="libcurl",对windows是支持的,https:// + ftps://urls,支持同时下载,url参数和

destfile参数可以是等长的字符向量

3.method="internal",不遵循http:// + https://重定向.method="wininet"支持部分重定向

4.https://,windows中不支持method="internal",支持method="libcurl"和"wininet"

二.downloader包-download函数

Download a file, using http, https, or ftp.与download.file()函数唯一的区别:如果是HTTPS协议,更改了一些设置使其运行

windows:"wininet"+"internal"

其他系统:"libcurl"+"wget"->"curl"->"lynx"

R gui通常具有libcurl method

猜你喜欢

转载自blog.csdn.net/qq_38984677/article/details/81488063