14 lines
685 B
Python
Executable File
14 lines
685 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""page.py PATH... — log in (ctl.py; the password by env NAME under `sec run`) and print each page's visible text,
|
|
whitespace-collapsed, plus whether named phrases appear. Endpoint-level: the same GETs a browser sends."""
|
|
import html, os, re, sys
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
import ctl
|
|
ctl.login()
|
|
for path in sys.argv[1:]:
|
|
body = ctl._curl(["-L", "-H", "Cookie: " + ctl._SESS, ctl.BASE + path])
|
|
body = re.sub(r"<(script|style)[^>]*>.*?</\1>", "", body, flags=re.S)
|
|
txt = re.sub(r"\s+", " ", html.unescape(re.sub(r"<[^>]+>", " ", body))).strip()
|
|
print(f"=== {path} ({len(body)} bytes)")
|
|
print(txt[:2500])
|