mirror of
https://github.com/briatte/awesome-network-analysis.git
synced 2025-02-01 00:44:59 -05:00
better log
This commit is contained in:
parent
3f9c3556d0
commit
d40d015424
41
check.r
41
check.r
@ -31,30 +31,53 @@ l <- c(
|
|||||||
|
|
||||||
stopifnot(length(l) == t)
|
stopifnot(length(l) == t)
|
||||||
|
|
||||||
l <- unique(l)
|
l <- unique(l) %>%
|
||||||
|
sort
|
||||||
|
|
||||||
cat(length(l), "unique\n")
|
cat(length(l), "unique\n")
|
||||||
|
|
||||||
for (i in l) {
|
sink("check.log", append = FALSE)
|
||||||
|
cat(as.character(Sys.time()), ": checking", length(l), "URLs\n\n")
|
||||||
|
sink()
|
||||||
|
|
||||||
if (!which(l == i) %% 50)
|
for (i in l) {
|
||||||
cat(length(l) - which(l == i), "left\n")
|
|
||||||
|
|
||||||
x <- try(GET(i) %>%
|
x <- try(GET(i) %>%
|
||||||
status_code,
|
status_code,
|
||||||
silent = TRUE)
|
silent = TRUE)
|
||||||
|
|
||||||
if (!"try-error" %in% class(x) && x != 200) {
|
if (!"try-error" %in% class(x) && x != 200) {
|
||||||
cat("x")
|
|
||||||
|
cat("X")
|
||||||
|
|
||||||
sink("check.log", append = TRUE)
|
sink("check.log", append = TRUE)
|
||||||
cat("\nURL:", i, "\nStatus code:", x, "\n")
|
cat(i, "\nStatus code:", x, "\n\n")
|
||||||
sink()
|
sink()
|
||||||
|
|
||||||
} else if("try-error" %in% class(x)) {
|
} else if("try-error" %in% class(x)) {
|
||||||
cat("x")
|
|
||||||
|
cat("?")
|
||||||
|
|
||||||
sink("check.log", append = TRUE)
|
sink("check.log", append = TRUE)
|
||||||
cat("\nURL:", i, "\nFailed to access\n.")
|
cat(i, "\nFailed to access\n\n")
|
||||||
sink()
|
sink()
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
cat(".")
|
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…
x
Reference in New Issue
Block a user