# -*- 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 / "cornell-acct").read_text(encoding="utf-8", errors="ignore") if False else (CACHE / "cornell-acct.html").read_text(encoding="utf-8", errors="ignore"))
i = t.find("Programs & Degrees")
j = t.find("deadline")
print(t[j-1500:j+2500])
print("---- TUITION ----")
k = t.find("Tuition")
print(t[k-800:k+1200])
