# -*- 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\cache"
for name in ["r347-dart-cs", "r347-emory-cs", "r347-nd-cse", "r347-rice-cs", "r347-uchi-stat", "r347-cmu-ini-msis"]:
    t = open(BASE + "\\" + name + ".html", encoding="utf-8", errors="replace").read()
    print("=== ", name, len(t))
    links = re.findall(r'<a[^>]+href="([^"]+)"[^>]*>(.*?)</a>', t, re.S)
    out = []
    for h, txt in links:
        txt = re.sub(r"<[^>]+>", "", txt).strip()
        if len(txt) < 4:
            continue
        if re.search(r"(master|Master|MS |M\.S|graduate|Graduate|curriculum|Curriculum|course|Course)", txt) or re.search(r"(master|graduate|curriculum|course)", h, re.I):
            out.append(f"{h[:100]} | {txt[:55]}")
    for o in out[:18]:
        print("   ", o)
