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

for k in ["wlu-cs-mmath-p", "wlu-mdsai-p"]:
    t = open(BASE + "\\_r348-new-" + k + ".txt", encoding="utf-8").read()
    for kw in ["Program requirements", "Degree requirements", "required courses", "Required courses", "Research", "program consists", "The program"]:
        i = t.find(kw)
        if i > 0:
            print("\n###", k, "|", kw)
            print(re.sub(r"\s+", " ", t[i:i+900]))

print("\n\n=========== BROWN MASTERS")
h = open(BASE + r"\cache\r348-masters.html", encoding="utf-8", errors="replace").read()
h = re.sub(r"<script.*?</script>", " ", h, flags=re.S)
h = re.sub(r"<style.*?</style>", " ", h, flags=re.S)
h = re.sub(r"<[^>]+>", "\n", h)
h = re.sub(r"&nbsp;", " ", h); h = re.sub(r"&amp;", "&", h)
h = re.sub(r"\n\s*\n+", "\n", h)
open(BASE + r"\_r348-new-brown-masters.txt", "w", encoding="utf-8").write(h)
print("chars", len(h))
print(re.sub(r"\s+", " ", h)[:3000])
