# -*- coding: utf-8 -*-
import re, io, sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')

p = "index_main.html"
html = open(p, encoding="utf-8").read()

ids = [
    "princeton-ece-phd", "harvard-ece-phd", "caltech-cs-phd",
    "berkeley-eecs-phd", "mit-eecs-phd", "cornell-ece-phd",
    "umich-ece-phd", "geo-cs-phd",
]

m = re.search(r'const PROGRAMS\s*=\s*\[(.*?)\];', html, re.S)
block = m.group(1)
recs = re.findall(r'\{id:"([^"]+)"([\s\S]*?)(?=\{id:"|$)', block)
by = {r[0]: r[1] for r in recs}
print("PROGRAMS total:", len(by))
for i in ids:
    if i in by:
        print("\n###", i)
        print(by[i].strip()[:400])
    else:
        print("\n###", i, "NOT FOUND")
