Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
756 views
in Technique[技术] by (71.8m points)

r - Retrieve the list of files from a URL

I would like to get a list of all the files available at this address: http://www1.ncdc.noaa.gov/pub/data/cmb/drought/weekly-palmers/2005/ (publicly available data from the NOAA).

It would be some sort of "list.files" for the a specific URL. I started to take a look at RCurl but all I could get was the HTML code of the URL.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In this case you can simply use readHTMLTable:

readHTMLTable("http://www1.ncdc.noaa.gov/pub/data/cmb/drought/weekly-palmers/2005/", 
              skip.rows=1:2)[[1]]$Name -> file.list

Then to create a list of paths:

paste("http://www1.ncdc.noaa.gov/pub/data/cmb/drought/weekly-palmers/2005/", 
      file.list[!is.na(file.list)], sep="") -> path.list

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...