# -*- coding: utf-8 -*-
import re, io, sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
h = open('index_main.html', encoding='utf-8').read()
p0 = h.index("const PROGRAMS=["); p1 = h.index("const CATD=[")
seg = h[p0:p1]
for pid in ["nyu-econ","usc-stat"]:
    m = re.search(r'\{id:"'+pid+r'"([\s\S]*?)(?=\{id:"|,?\n\];)', seg)
    if m:
        print("====", pid, "====")
        for f in ["ddl","lang","tui"]:
            mm = re.search(f+r':"([^"]*)"', m.group(0))
            print(f"  {f}: {mm.group(1) if mm else '(缺)'}")
        tm = re.search(r'test:\{cls:"([^"]*)"', m.group(0))
        print(f"  test: {tm.group(1) if tm else '(缺)'}")
        um = re.search(r'url:"([^"]*)"', m.group(0))
        print(f"  url: {um.group(1) if um else '(缺)'}")
