# -*- coding: utf-8 -*-
import io, sys, os, re, collections
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")
t=open("index_main.html",encoding="utf-8").read()
s=t[t.find("const PROGRAMS="):t.find("const CATD=")]
print("total", len(re.findall(r'\{id:"', s)))
print("lvl", collections.Counter(re.findall(r'lvl:"([^"]+)"', s)))
new=["jhu-ehe-ma","jhu-ehe-mse","duke-medphys-ms","yale-che-ms","harvard-seas-sm"]
for nid in new:
    m=re.search(r'\{id:"'+re.escape(nid)+r'",[\s\S]*?url:"([^"]+)"', s)
    if m:
        c=m.group(0)
        deg=re.search(r'deg:"([^"]+)"',c); stem=re.search(r'stem:(\d)',c)
        cls=re.search(r'test:\{cls:"([^"]*)"\}',c); disc=re.search(r'disc:"([^"]+)"',c)
        print(nid,"|",deg.group(1),"|",disc.group(1),"|stem",stem.group(1),"|cls",repr(cls.group(1)),"|",m.group(1))
    else:
        print(nid,"NOT FOUND")
for det in ["details/jhu-cefa6e1.html","details/jhu-c1d5ed0.html","details/duke-c710a43.html","details/yale-chemical-environmental-engineering.html","details/harvard-engineering-and-applied-sciences.html"]:
    h=open(det,encoding="utf-8").read()
    print(det,"bytes",len(h),"h2",h.count("<h2>"),"外链",h.count('target="_blank"'))
