Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

url.exists

Check if URL exists


Description

This functions is analogous to file.exists and determines whether a request for a specific URL responds without error. We make the request but ask the server not to return the body. We just process the header.

Usage

url.exists(url, ..., .opts = list(...),
            curl = getCurlHandle(.opts = .opts),
             .header = FALSE)

Arguments

url

a vector of one or more URLs whose existence we are to test

...

name = value pairs of Curl options.

.opts

a list of name = value pairs of Curl options.

curl

a Curl handle that the caller can specify if she wants to reuse an existing handle, e.g. with different options already specified or that has previously established a connection to the Web server

.header

a logical value that if TRUE causes the header information to be returned.

Details

This makes an HTTP request but with the nobody option set to FALSE so that we don't actually retrieve the contents of the URL.

Value

If .header is FALSE, this returns TRUE or FALSE for each URL indicating whether the request was successful (had a status with a value in the 200 range).

If .header is TRUE, the header is returned for the request for each URL.

Author(s)

Duncan Temple Lang

References

HTTP specification

See Also

Examples

url.exists("http://www.omegahat.net/RCurl")
 try(url.exists("http://www.omegahat.net/RCurl-xxx"))

RCurl

General Network (HTTP/FTP/...) Client Interface for R

v1.98-1.3
BSD_3_clause + file LICENSE
Authors
CRAN Team [ctb, cre] (de facto maintainer since 2013), Duncan Temple Lang [aut] (<https://orcid.org/0000-0003-0159-1546>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.