【发布时间】:2019-01-04 23:17:40
【问题描述】:
我正在尝试从此链接下载所有 .gz 文件: ftp://ftp.ncbi.nih.gov/snp/organisms/human_9606_b151_GRCh38p7/BED/
到目前为止,我尝试了这个,但没有得到任何结果:
require(RCurl)
url= "ftp://ftp.ncbi.nih.gov/snp/organisms/human_9606_b151_GRCh38p7/BED/"
filenames = getURL(url, ftp.use.epsv = FALSE, dirlistonly = TRUE)
filenames <- strsplit(filenames, "\r\n")
filenames = unlist(filenames)
我收到此错误:
Error in function (type, msg, asError = TRUE) :
Operation timed out after 300552 milliseconds with 0 out of 0 bytes received
有人可以帮忙吗?
谢谢
编辑: 我尝试使用下面提供给我的文件名运行,所以在我的 r 脚本中我有:
require(RCurl)
my_url <-"ftp://ftp.ncbi.nih.gov/snp/organisms/human_9606_b151_GRCh38p7/BED/"
my_filenames= c("bed_chr_11.bed.gz", ..."bed_chr_9.bed.gz.md5")
my_filenames <- strsplit(my_filenames, "\r\n")
my_filenames = unlist(my_filenames)
for(my_file in my_filenames){
download.file(paste0(my_url, my_file), destfile = file.path('/mydir', my_file))
}
当我运行脚本时,我会收到以下警告:
trying URL 'ftp://ftp.ncbi.nih.gov/snp/organisms/human_9606_b151_GRCh38p7/BED/bed_chr_11.bed.gz'
download.file(paste0(my_url, my_file), destfile = file.path("/mydir", ) 中的错误: 无法打开 URL 'ftp://ftp.ncbi.nih.gov/snp/organisms/human_9606_b151_GRCh38p7/BED/bed_chr_11.bed.gz' 另外:警告信息: 在 download.file(paste0(my_url, my_file), destfile = file.path("/mydir", : URL 'ftp://ftp.ncbi.nih.gov/snp/organisms/human_9606_b151_GRCh38p7/BED/bed_chr_11.bed.gz': 状态为'已超时' 执行停止
【问题讨论】:
-
抱歉,只是为了澄清一下,您发布的代码对您有用吗?我问是因为它对我有用,所以我不确定你在哪里得到错误。
-
不,它没有。在此行之后失败:filenames = getURL(url, ftp.use.epsv = FALSE, dirlistonly = TRUE)