我在尝试使用 url 下载 ftp 链接时遇到错误

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

这是我在尝试 URL 'ftp://gdo-dcp.ucllnl.org/pub/dcp/subset/202404050438gr5H_n_1msibTNA' 时遇到的错误 download.file 中的错误(粘贴(url,文件名,sep =“”),粘贴(getwd(),: 无法打开 URL“ftp://gdo-dcp.ucllnl.org/pub/dcp/subset/202404050438gr5H_n_1msibTNA” 另外:警告消息: 在download.file(粘贴(url,文件名,sep =“”),粘贴(getwd(),: 无法打开 URL“ftp://gdo-dcp.ucllnl.org/pub/dcp/subset/202404050438gr5H_n_1msibTNA”:FTP 状态为“550 未采取请求的操作;文件不可用'

我用了这个代码

library(RCurl)
library(data.table)
# Set the location where data should be saved
setwd("D:/hydrology_climate/access0")
# Change to the FTP url for the subset request. This is provided in the
# DCP notification email (sent from [email protected]).
options(download.file.method="libcurl", url.method="libcurl")
url = "ftp://gdo-dcp.ucllnl.org/pub/dcp/subset/202404050438gr5H_n_1msibT"
filenames = getURL(url, ftp.use.epsv = FALSE, dirlistonly = TRUE)
filenames <- strsplit(filenames, "\r\n")
filenames = unlist(filenames)
tmp = data.table(filenames)
zips = tmp[filenames %like% 'zip']
txts = tmp[filenames %like% 'txt']

nzips = as.numeric(nrow(zips))
for (i in 1:nzips) {
filename = zips[i]
download.file(paste(url, filename, sep = ""), paste(getwd(), "/", filename,sep = ""))
}
 ntxts = as.numeric(nrow(txts))
for (i in 1:ntxts) {
filename = txts[i]
download.file(paste(url, filename, sep = ""), paste(getwd(), "/", filename,sep = ""))
}
python r ftp data.table rcurl
1个回答
0
投票

FTP 上似乎没有文件

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