# -*- coding: utf-8 -*-
import re, io, sys, os
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")
idx = open("index_main.html", encoding="utf-8").read()
catd_seg = idx[idx.find("const CATD="):idx.find("const VERIFIED_DETAILS=")]
prog_seg = idx[idx.find("const PROGRAMS="):idx.find("const CATD=")]

kws = ["computer science", "mathematics", "statistics", "economics", "finance", "management", "accounting"]
print("=== CATD 占位 ===")
chunks = re.findall(r'\["ut",[^\]]+\]', catd_seg)
for c in chunks:
    low = c.lower()
    for k in kws:
        if k in low:
            print(c[:220])
            break

print("\n=== PROGRAMS 已录 ut 相关 ===")
pchunks = re.split(r'(?=\{id:")', prog_seg)
for c in pchunks:
    if not c.startswith('{id:"'): continue
    if 's:"ut"' not in c: continue
    en = re.search(r'en:"([^"]+)"', c)
    low = (en.group(1) if en else "").lower()
    for k in kws:
        if k in low:
            idm = re.search(r'id:"([^"]+)"', c)
            url = re.search(r'url:"([^"]+)"', c)
            print(idm.group(1) if idm else "", "|", en.group(1) if en else "", "|", url.group(1) if url else "")
            break
