Skip to content

Instantly share code, notes, and snippets.

@mittenchops
Created April 12, 2013 19:15
Show Gist options
  • Save mittenchops/5374397 to your computer and use it in GitHub Desktop.
Save mittenchops/5374397 to your computer and use it in GitHub Desktop.
test whether Urls are valid in R, uses a fancy Filter funcion
mylist = c('www.google.com','www.google.comascascasdasdnasmdamsd')
isgoodURL <- function(url){if(system(paste('curl -o /dev/null --silent --head --fail ', url)) == 0) return(TRUE) else return(FALSE)}
Filter(isgoodURL,mylist)
@mittenchops
Copy link
Author

$ echo $(curl --write-out "%{http_code}\n" -o /dev/null --silent "https://www.google.com/123123")
404
$ echo $(curl --write-out "%{http_code}\n" -o /dev/null --silent "https://www.google.com")
200

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment