read paths and request tom and temmie
This commit is contained in:
+29
-1
@@ -1,4 +1,32 @@
|
||||
import requests
|
||||
import os
|
||||
|
||||
# substrings in path to exclude
|
||||
EXCLUDES = [
|
||||
"wordpress"
|
||||
]
|
||||
|
||||
def read_lines(path: str) -> list[str]:
|
||||
with open(path, 'r') as f:
|
||||
return f.read().splitlines()
|
||||
|
||||
# construct get-able url path
|
||||
def parse_path(path: str) -> str:
|
||||
# bet on `/home/pvv/_/` prefix
|
||||
return "~" + path[12:] |> .replace("/web-docs", "")
|
||||
|
||||
def include_path(path: str) -> bool:
|
||||
return not any([x in path for x in EXCLUDES])
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("hello world")
|
||||
filtered_paths = read_lines("out/cgi-paths.txt") |> map$(parse_path) |> filter$(include_path) |> list
|
||||
|
||||
print("----- TOM -----")
|
||||
tom_paths = filtered_paths |> map$("https://pvv.ntnu.no/"+.) |> list
|
||||
tom_oks = tom_paths |> map$(requests.get) |> map$(x -> x.ok) |> list
|
||||
zip(tom_oks, tom_paths) |> map$(x -> str(x[0]) + ":\t" + x[1]) |> "\n".join |> print
|
||||
|
||||
print("----- TEMMIE -----")
|
||||
tem_paths = filtered_paths |> map$("https://temmie.pvv.ntnu.no/"+.) |> list
|
||||
tem_oks = tem_paths |> map$(requests.get) |> map$(x -> x.ok) |> list
|
||||
zip(tem_oks, tem_paths) |> map$(x -> str(x[0]) + ":\t" + x[1]) |> "\n".join |> print
|
||||
|
||||
Reference in New Issue
Block a user