mirror of
https://github.com/briatte/awesome-network-analysis.git
synced 2025-01-20 11:31:29 -05:00
better log
This commit is contained in:
parent
3f9c3556d0
commit
d40d015424
39
check.r
39
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")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user