# -*- 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"

def txt(p):
    h = open(BASE + "\\cache\\" + p, 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 = h.replace("&nbsp;", " ").replace("&amp;", "&")
    return re.sub(r"\n\s*\n+", "\n", h)

for k in ["r348-wlu-fin-gradprog.html", "r348-wlu-fund-ctuition.html"]:
    t = txt(k)
    s = re.sub(r"\s+", " ", t)
    print("\n=====", k, len(s))
    for kw in ["Mathematics", "Master of Mathematics", "per term", "Rate", "International"]:
        i = s.find(kw)
        if i > 0:
            print("  --", kw, ":", s[i:i+600])
