import re, os, sys, io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
base = os.path.dirname(os.path.abspath(__file__))
r = open(os.path.join(base,"index_main.html"), encoding="utf-8").read()
ids=["cmu-msin","cmu-msis","duke-aipi","cmu-msm-ms","uw-mdsai-coop","geo-bioinfo-ms"]
for i in ids:
    m=re.search(r'\{id:"'+re.escape(i)+r'[\s\S]*?(?=\{id:"|$)', r)
    if m:
        cm=re.search(r'test:\{cls:"([^"]*)"\}', m.group(0))
        url=re.search(r'url:"([^"]*)"', m.group(0))
        print(f"[{i}] cls={cm.group(1) if cm else '?'} | {url.group(1) if url else '?'}")
print()
# 详情页标化行检查
det={
 "cmu-msin":"details/cmu-msin.html",
 "cmu-msis":"details/cmu-msis.html",
 "duke-aipi":"details/duke-aipi.html",
 "cmu-msm-ms":"details/cmu-cdd17fa.html",
 "uw-mdsai-coop":"details/uw-c2f6425.html",
 "geo-bioinfo-ms":"details/geo-bioinformatics-ms.html",
}
for i,d in det.items():
    p=os.path.join(base,d.replace("/",os.sep))
    if not os.path.exists(p):
        print(f"[{i}] 详情页缺失 {d}"); continue
    h=open(p,encoding="utf-8",errors="ignore").read()
    has=bool(re.search(r'GRE|GMAT|EA ',h))
    # 找包含 GRE/GMAT 的行
    lines=[ln.strip() for ln in h.splitlines() if re.search(r'GRE|GMAT|Executive Assessment',ln)]
    print(f"[{i}] {d} | 含标化: {has}")
    for ln in lines[:3]:
        print("    ", re.sub(r'<[^>]+>','',ln).strip()[:110])
