R/urlExists.R

Defines functions urlExists

Documented in urlExists

#' @title urlExists
#' @description A utility function to run a tryCatch on a URL.
#' @param target url
#' @export
urlExists <- function(target) {  
    tryCatch({  
        con <- url(target)  
        a  <- capture.output(suppressWarnings(readLines(con)))  
        close(con)  
        TRUE;  
    },  
    error = function(err) {  
        occur <- grep("cannot open the connection", capture.output(err));  
        if(length(occur) > 0) FALSE;  
    }  
    )  
}  
keberwein/krisUtils documentation built on May 20, 2019, 5:26 p.m.