check if a URL can be reached, return TRUE if yes and FALSE if cannot or with other status code

checkUrl(url, timeout = 5)

Arguments

url

string, the URL to request

timeout

seconds to wait before return FALSE

Value

TRUE if url is reachable, FALSE if not

Examples

checkUrl("https://google.com")
#> [1] TRUE
try(checkUrl("https://randomwebsite123.com", 1))
#> Warning: 
[WARNING] 2021-10-30 02:04:08 Bad url https://randomwebsite123.com
#> Warning: 
[WARNING] 2021-10-30 02:04:08 Could not resolve host: randomwebsite123.com
#> [1] FALSE