# -*- 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()

for k in ["cornell-acct", "nyu-msacc", "vandy-cs"]:
    t = txt((CACHE / (k + ".html")).read_text(encoding="utf-8", errors="ignore"))
    print("#" * 20, k, len(t))
    for kw in ["Tuition", "tuition", "Deadline", "deadline", "Round", "Application", "curriculum", "Curriculum", "credits"]:
        idx = [m.start() for m in re.finditer(kw, t)]
        if idx:
            print("--", kw, len(idx))
    print(t[:1200])
    print()
