# -*- 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.html").read_text(encoding="utf-8", errors="ignore"))
i = t.find("MPS Accounting curriculum")
print("=== CORNELL CURRICULUM ===")
print(t[i:i+2500])
j = t.find("Prerequisite")
print("=== PREREQ ===", j)
print(t[j-200:j+1500] if j > 0 else "")
