# -*- coding: utf-8 -*-
import io, sys, os, re, json
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=")]

# search by keywords in CATD
keys=[
 ("cheme", ["Chemical Engineering","Chemical engineering","chemical engineering"]),
 ("math", ["Mathematics","Mathematics"]),
 ("biochem", ["Biochemistry","biochemistry"]),
 ("mgmt", ["Master of Management","Management","MMgt"]),
 ("hpme", ["Health Policy","Health Services","Health Evaluation"]),
]
for tag, kws in keys:
    print("="*60)
    print(tag)
    for line in catd_seg.split("],"):
        if '"ut"' in line:
            for kw in kws:
                if kw in line:
                    m=re.search(r'"(details/ut-[0-9a-f]+\.html)"', line)
                    det=m.group(1) if m else "?"
                    en=re.search(r'"([^"]+)"', line.split('"ut"')[1] if '"ut"' in line else "")
                    print(" ",det, "|", line.strip()[:200])
                    break
