get status_code instead of ok
This commit is contained in:
+7
-7
@@ -19,14 +19,14 @@ def parse_path(path: str) -> str:
|
|||||||
def include_path(path: str) -> bool:
|
def include_path(path: str) -> bool:
|
||||||
return not any([x in path for x in EXCLUDES])
|
return not any([x in path for x in EXCLUDES])
|
||||||
|
|
||||||
def safe_get(path: str) -> bool:
|
def safe_get(path: str) -> str:
|
||||||
try:
|
try:
|
||||||
return requests.get(path).ok
|
return requests.get(path).status_code |> str
|
||||||
except:
|
except Exception as e:
|
||||||
return False
|
return str(e)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
output_file = "out/status.txt"
|
output_file = "out/status2.txt"
|
||||||
print(f"writing to file `{output_file}`...")
|
print(f"writing to file `{output_file}`...")
|
||||||
sys.stdout = open(output_file, "w")
|
sys.stdout = open(output_file, "w")
|
||||||
|
|
||||||
@@ -35,12 +35,12 @@ if __name__ == "__main__":
|
|||||||
print("----- TOM -----")
|
print("----- TOM -----")
|
||||||
tom_paths = filtered_paths |> map$("https://pvv.ntnu.no/"+.) |> list
|
tom_paths = filtered_paths |> map$("https://pvv.ntnu.no/"+.) |> list
|
||||||
tom_oks = tom_paths |> map$(safe_get) |> list
|
tom_oks = tom_paths |> map$(safe_get) |> list
|
||||||
zip(tom_oks, tom_paths) |> map$(x -> str(x[0]) + ":\t" + x[1]) |> "\n".join |> print
|
zip(tom_oks, tom_paths) |> map$(":\t".join) |> "\n".join |> print
|
||||||
|
|
||||||
print("----- TEMMIE -----")
|
print("----- TEMMIE -----")
|
||||||
tem_paths = filtered_paths |> map$("https://temmie.pvv.ntnu.no/"+.) |> list
|
tem_paths = filtered_paths |> map$("https://temmie.pvv.ntnu.no/"+.) |> list
|
||||||
tem_oks = tem_paths |> map$(safe_get) |> list
|
tem_oks = tem_paths |> map$(safe_get) |> list
|
||||||
zip(tem_oks, tem_paths) |> map$(x -> str(x[0]) + ":\t" + x[1]) |> "\n".join |> print
|
zip(tem_oks, tem_paths) |> map$(":\t".join) |> "\n".join |> print
|
||||||
|
|
||||||
sys.stdout.close()
|
sys.stdout.close()
|
||||||
sys.stdout = sys.__stdout__
|
sys.stdout = sys.__stdout__
|
||||||
|
|||||||
Reference in New Issue
Block a user