# -*- 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=["usc-msba","cornell-aem-ms","cornell-mps-mgmt","cornell-mmh","uw-mdsai-coop"]
for nid in new:
    m=re.search(r'\{id:"'+re.escape(nid)+r'",[\s\S]*?url:"([^"]+)"', s)
    if m:
        chunk=m.group(0)
        deg=re.search(r'deg:"([^"]+)"',chunk)
        stem=re.search(r'stem:(\d)',chunk)
        cls=re.search(r'test:\{cls:"([^"]*)"\}',chunk)
        print(nid,"|",deg.group(1),"|stem",stem.group(1),"|cls",repr(cls.group(1)),"|",m.group(1))
    else:
        print(nid,"NOT FOUND")

for det in ["details/usc-msba.html","details/cornell-c4ed07c.html","details/cornell-c3b1b9a.html","details/cornell-c7c652f.html","details/uw-c2f6425.html"]:
    if os.path.exists(det):
        h=open(det,encoding="utf-8").read()
        print(det,"bytes",len(h),"h2",h.count("<h2>"),"外链",h.count('target="_blank"'))
    else:
        print(det,"MISSING")
