# -*- coding: utf-8 -*-
import json, re, io, sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
BASE = r"D:\work buddy\2026-11-05-14-15-52"
IDS = ["jhu-mkt", "jhu-finance-ms", "jhu-finfe-ms", "jhu-hcm-ms", "jhu-engmgmt-ms",
       "jhu-msf", "jhu-finmath", "jhu-gis-ms", "jhu-c5ed8dc", "jhu-c785e3d", "jhu-energy"]
s = open(BASE + r"\index_main.html", encoding="utf-8").read()
seg = s[s.index("const PROGRAMS=["):s.index("const CATD=[")]
parts = seg.split('{id:"')[1:]
for p in parts:
    pid = p[:p.index('"')]
    if pid not in IDS:
        continue
    def g(k):
        m = re.search(k + r':"((?:[^"\\]|\\.)*)"', p)
        return m.group(1) if m else ""
    print(pid, "|", g("n"), "|", g("en"), "|", g("dept"), "|", g("college"), "|", g("disc"), "|", g("deg"), "|", g("lvl"))
    for k in ("dur", "ddl", "lang", "test", "tui", "url"):
        m = re.search(k + r':(\{[^}]*\}|"(?:[^"\\]|\\.)*")', p)
        print("   ", k, "=", (m.group(1) if m else "")[:160])
