This function opens a connection to the specified URL to check its validity.
It returns TRUE if the URL is valid (i.e., the connection can be opened),
and FALSE otherwise.
Source
The source code of this function was taken from this
stackoverflow discussion.
Arguments
- URL
Character. The URL to be checked.
- t
Numeric. Timeout in seconds for the connection attempt. Default is
2 seconds.
Value
A logical value: TRUE if the URL is valid, FALSE if not.
Examples
urls <- c(
"http://www.amazon.com", "http://this.isafakelink.biz",
"https://stackoverflow.com", "https://stack-overflow.com")
sapply(urls, CheckURL)
#> http://www.amazon.com http://this.isafakelink.biz
#> TRUE FALSE
#> https://stackoverflow.com https://stack-overflow.com
#> TRUE TRUE