【发布时间】:2016-03-09 04:55:00
【问题描述】:
我想下载所有这些文件,解压缩并导入到 R,但多次尝试后下载失败。
这是我尝试过的代码(来自以前的帖子):
library(Rcurl)
url <- "ftp://ftp.nrcan.gc.ca/pub/outgoing/canada_daily_grids/"
protocol <- getURL(url,ftp.use.epsv=TRUE, dirlistonly=TRUE)
filenames <- protocol <- strsplit(protocol, "\r*\n")[[1]]
write.table(filenames, "names.txt", sep="\t")
zips <- sapply(filenames,function(x) substr(x,nchar(x)-2,nchar(x)))== "zip"
downloads <- filenames[zips]
con <- getCurlHandle(ftp.use.epsv = TRUE)
mapply(function(x,y) writeBin(getBinaryURL(x, curl = con, dirlistonly = FALSE), y), x = downloads, y = paste("C://dat/",downloads, sep = ""))
但我得到了错误:
Error in function (type, msg, asError = TRUE) :
Failed to connect to ... port 80: Connection refused
【问题讨论】: