diff --git a/check.r b/check.r index 68c03b6..a5b257a 100644 --- a/check.r +++ b/check.r @@ -31,30 +31,53 @@ l <- c( stopifnot(length(l) == t) -l <- unique(l) +l <- unique(l) %>% + sort + cat(length(l), "unique\n") +sink("check.log", append = FALSE) +cat(as.character(Sys.time()), ": checking", length(l), "URLs\n\n") +sink() + for (i in l) { - if (!which(l == i) %% 50) - cat(length(l) - which(l == i), "left\n") - x <- try(GET(i) %>% status_code, silent = TRUE) if (!"try-error" %in% class(x) && x != 200) { - cat("x") + + cat("X") + sink("check.log", append = TRUE) - cat("\nURL:", i, "\nStatus code:", x, "\n") + cat(i, "\nStatus code:", x, "\n\n") sink() + } else if("try-error" %in% class(x)) { - cat("x") + + cat("?") + sink("check.log", append = TRUE) - cat("\nURL:", i, "\nFailed to access\n.") + cat(i, "\nFailed to access\n\n") sink() + } else { + cat(".") + } + if (!which(l == i) %% 50) + cat("", length(l) - which(l == i), "left\n") + } + +sink("check.log", append = TRUE) +cat(as.character(Sys.time()), ": done.\n") +sink() + +cat("Found", str_count(readLines("check.log"), "^http:") %>% + sum, + "problems.\n") +