# -*- coding: utf-8 -*-
import re, pathlib, sys, io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
BASE = pathlib.Path(r"D:\work buddy\2026-11-05-14-15-52"); CACHE = BASE / "cache"
def clean(t):
    t = re.sub(r"<script.*?</script>", " ", t, flags=re.S)
    t = re.sub(r"<style.*?</style>", " ", t, flags=re.S)
    t = t.replace("&nbsp;", " ").replace("&amp;", "&").replace("&#39;", "'")
    t = re.sub(r"<[^>]+>", "\n", t)
    return [re.sub(r"\s+", " ", x).strip() for x in t.split("\n") if x.strip()]
for f in ["gt3-mse-adm.html", "gt3-mse-grad.html"]:
    L = clean((CACHE / f).read_text(encoding="utf-8", errors="ignore"))
    print("=====", f, len(L))
    for i, x in enumerate(L):
        if re.search(r"deadline|Deadline|GRE|TOEFL|IELTS|January|December|Fall", x):
            print(i, x[:160])
