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

问题描述 投票:1回答:2

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

根据Getting and Cleaning Data课程,我尝试使用method = curl下载csv文件:

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

download.file中的错误(fileUrl,destfile =“./ camera.sv”,method =“curl”):'curl'调用具有非零退出状态

但是,method = libcurl成功下载:

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

尝试URL'https://data.baltimorecity.gov/api/views/dz54-2aru/rows.csv?accessType=DOWNLOAD'下载了9443个字节

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

无论如何根据课程通过method = curl进行下载工作?

谢谢

r curl download libcurl
2个回答
1
投票

?download.file可以看到:

对于方法“wget”和“curl”,系统调用由方法给出的工具,并且相应的程序必须安装在您的系统上并且位于可执行文件的搜索路径中。它们将阻止R进程上的所有其他活动,直到它们完成:这可能会使GUI无响应。

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


1
投票

我相信这里有一些问题:遵循@JonnyCrunch引用的链接中的步骤

a)为Windows重新安装Git;

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

c)禁用在RStudio中使用Internet Explorer库/代理进行HTTP:工具>选项>包

d)尝试下面的“e)”步骤,并根据卡巴斯基反病毒提示将data.baltimorecity.gov网站添加到排除项中;

e)然后在RStudio中:

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

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

成功!

谢谢

© www.soinside.com 2019 - 2024. All rights reserved.