使用 R 列出来自 https 服务器的文件

list files from https sever using R

我在尝试使用 R ([https://oceandata.sci.gsfc.nasa.gov/MODIS-Aqua/Mapped/Monthly/4km/sst/][1])

列出来自此 https 服务器的所有文件时遇到问题

列出所有文件名后,我想下载 last/newest 文件

有人可以帮助我吗?

这是我尝试使用的简码,但仍然无法使用

url<-'  https://oceandata.sci.gsfc.nasa.gov/MODIS-Aqua/Mapped/Monthly/4km/sst/'
f1<-getURL(url, curl = curl)
download.file('https://oceandata.sci.gsfc.nasa.gov/cgi/getfile/A20021822002212.L3m_MO_SST_sst_4km.nc', destfile = desf[length(f2)], mode = "wb")  

1]: https://oceandata.sci.gsfc.nasa.gov/MODIS-Aqua/Mapped/Monthly/4km/sst/

以下对我有用:

library(httr)
library(XML)

df <- readHTMLTable(content(GET("https://oceandata.sci.gsfc.nasa.gov/MODIS-Aqua/Mapped/Monthly/4km/sst"), "text"))[[1]]

download.file(paste0("https://oceandata.sci.gsfc.nasa.gov/cgi/getfile/", 
    tail(df,1)$Filename), tail(df,1)$Filename, mode = "wb")