# -*- coding: utf-8 -*-
import re, sys, io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
idx = open(r"D:\work buddy\2026-11-05-14-15-52\index_main.html", encoding="utf-8").read()
seg = idx[idx.find("const PROGRAMS="):idx.find("const CATD=")]
# 查 5 个候选英文名是否已在 PROGRAMS
keys = [
    ("AI MSE", "Artificial Intelligence"),
    ("DS MSE", "Data Science"),
    ("Stats MA", "Statistics and Data Science"),
    ("MSQF", "Quantitative Finance"),
    ("CIS MSE", "Computer and Information Science"),
]
for tag, kw in keys:
    matches = [m.start() for m in re.finditer(re.escape(kw), seg, re.I)]
    print(f"=== {tag} ({kw}) : {len(matches)} hits ===")
    for m in matches[:5]:
        print("   ...", seg[max(0,m-80):m+120].replace("\n"," "))
# 也查 UPenn 已录的所有 en 列表
print("\n=== UPenn 已录 en 列表 ===")
for m in re.finditer(r'\{id:"up-",\s*s:"up",\s*n:"([^"]+)",\s*en:"([^"]+)"', seg):
    print("  ", m.group(1), "|", m.group(2))
