import re, json
h = open('index_main.html', encoding='utf-8').read()
# extract PROGRAMS block
m = re.search(r'const PROGRAMS\s*=\s*\[(.*?)\];', h, re.DOTALL)
block = m.group(1)
recs = re.split(r'(?=\{id:")', block)
# schools to scan
target_schools = ['harvard','dartmouth','yale','brown','berkeley','ubc','mcg','illinois','princeton','mit']
by_school = {s: [] for s in target_schools}
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_school:
        by_school[s.group(1)].append({
            'id': sid.group(1),
            'n': n.group(1) if n else '',
            'en': en.group(1) if en else '',
            'deg': deg.group(1) if deg else ''
        })
for s, items in by_school.items():
    print(f"\n=== {s} ({len(items)}) ===")
    for it in items:
        print(f"  {it['id']:40s} | {it['deg']:5s} | {it['en'][:70]}")
