# -*- coding: utf-8 -*-
import sys, io, re, pathlib, html as H
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
CACHE = pathlib.Path(r"D:\work buddy\2026-11-05-14-15-52\cache")

def txt(x):
    x = re.sub(r"<script.*?</script>", " ", x, flags=re.S|re.I)
    x = re.sub(r"<style.*?</style>", " ", x, flags=re.S|re.I)
    x = re.sub(r"<br\s*/?>", "\n", x, flags=re.I)
    x = re.sub(r"</(p|div|li|tr|h\d|td|th)>", "\n", x, flags=re.I)
    x = re.sub(r"<[^>]+>", " ", x)
    x = H.unescape(x)
    x = re.sub(r"[ \t]+", " ", x)
    x = re.sub(r"\n\s*\n+", "\n", x)
    return x.strip()

t = txt((CACHE / "nyu-msacc.html").read_text(encoding="utf-8", errors="ignore"))
print("LEN", len(t))
print("MONEY", re.findall(r"\$\s?\d[\d,\.]*", t)[:20])
for kw in ["deadline", "Deadline", "credits", "Tuition", "tuition", "curriculum", "Curriculum", "Round"]:
    idx = [m.start() for m in re.finditer(kw, t)]
    print(kw, len(idx))
    if idx:
        print("   ", t[max(0, idx[0]-300):idx[0]+500].replace("\n", " | ")[:900])
