Check the existence of remote directory with R -
i check whether given directory exists in remote server, given url pointing directory. example:
url <- "http://plasmodb.org/common/downloads/release-24" how can accomplished in r? have considered using url.show, downloads , shows url if exists gives error in case of non-existent directory. not sure best approach, optimally without having download whole url in case of existing directory.
this highly dependent on server/resource in question since has more http status codes r capability. provided remote server configured respond directory index requests can use head httr this:
library(httr) status <- head("http://plasmodb.org/common/downloads/release-24/") status$status_code ## [1] 200 status <- head("http://plasmodb.org/common/downloads/release-100/") status$status_code ## [1] 404 here's nicely-formatted list of status codes http://httpstatus.es , here's salient rfc http://www.w3.org/protocols/rfc2616/rfc2616-sec10.html should peruse other sections of. finally, here's wikipedia link http://en.wikipedia.org/wiki/webserver_directory_index discussing "directory index". shows may 403 vs 200 or 404 depending on config (and it's not limited depending on web server).
Comments
Post a Comment