import re
h = open('index_main.html', encoding='utf-8').read()
m = re.search(r'const PROGRAMS\s*=\s*\[(.*?)\];', h, re.DOTALL)
block = m.group(1)
recs = re.split(r'(?=\{id:")', block)
target = ['berkeley','mcg','princeton','mit','harvard','dartmouth']
by = {s: [] for s in target}
for r in recs:
    r = r.strip().rstrip(',')
    if not r.startswith('{id:'): continue
    sid = re.search(r'\{id:"([^"]+)"', r)
    s = re.search(r's:"([^"]+)"', r)
    n = re.search(r'n:"([^"]*)"', r)
    en = re.search(r'en:"([^"]*)"', r)
    deg = re.search(r'deg:"([^"]*)"', r)
    if not (sid and s): continue
    if s.group(1) in by:
        by[s.group(1)].append((sid.group(1), deg.group(1) if deg else '', en.group(1) if en else ''))
for s, items in by.items():
    print(f"\n=== {s} ({len(items)}) ===")
    for it in items:
        print(f"  {it[0]:40s} | {it[1]:5s} | {it[2][:70]}")
