关于r:通过libcurl可以下载csv文件,但是不能通过curl方法下载

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

操作系统:Win 7 64位
RStudio版本1.1.463

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

方法下载一个csv文件

1
2
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成功下载:

1
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进行下载?

谢谢


我相信这里有一些问题:
遵循@JonnyCrunch

引用的链接中的步骤

a)重新安装了Windows的Git;

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

c)禁用在以下位置将RStudio中的Internet Explorer库/代理用于HTTP:工具>选项>包

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

e)然后在RStudio中:

1
2
3
options(download.file.method ="curl")

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

成功!

谢谢


?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
请参阅"如何在Windows上安装和使用curl"?学习如何。
最好!