下载 csv 文件通过 libcurl 工作但不通过 curl 方法

downloading csv file works via libcurl yet does not via curl method

OS: Win 7 64 位 RStudio 版本 1.1.463

根据获取和清理数据课程,我尝试使用 method = curl:

下载 csv 文件
fileUrl <- "https://data.baltimorecity.gov/api/views/dz54-2aru/rows.csv?accessType=DOWNLOAD"
download.file(fileUrl, destfile = "./cameras.csv", method = "curl") 

Error in download.file(fileUrl, destfile = "./cameras.csv", method = "curl") : 'curl' call had nonzero exit status

但是,method = libcurl导致下载成功:

download.file(fileUrl, destfile = "./cameras.csv", method = "libcurl")

trying URL 'https://data.baltimorecity.gov/api/views/dz54-2aru/rows.csv?accessType=DOWNLOAD' downloaded 9443 bytes

从 *http***s** 更改为 http 分别为 curllibcurl 产生了完全相同的结果。

是否可以根据课程通过 method = curl 进行下载?

谢谢

?download.file可以看出:

For methods "wget" and "curl" a system call is made to the tool given by method, and the respective program must be installed on your system and be in the search path for executables. They will block all other activity on the R process until they complete: this may make a GUI unresponsive.

因此,您应该先安装 curl。 请参阅此 How do I install and use curl on Windows? 了解操作方法。 最好!

我认为这里存在一些问题: 按照@JonnyCrunch

引用的link中的步骤进行操作

a) 为 windows 重新安装 Git;

b) 添加 C:\Program Files\Git\mingw64\bin\ 到 'PATH' 变量;

c) 在 RStudio 中禁用 为 HTTP 使用 Internet Explorer library/proxy:工具 > 选项 > 包

d) 尝试了下面 'e)' 中的步骤并添加了 data.baltimorecity.gov 要排除的网站 根据卡巴斯基反病毒软件的提示;

e) 然后在 RStudio 中:

options(download.file.method = "curl")

download.file(fileUrl, destfile="./data/cameras.csv")

成功!

谢谢