# -*- coding: utf-8 -*-
import io, sys, re, os, json
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
base = r"D:\work buddy\2026-11-05-14-15-52"
r = open(os.path.join(base,"index_main.html"), encoding="utf-8").read()

# CATD
c0=r.index("const CATD=["); c1=r.index("const VERIFIED_DETAILS")
pat=re.compile(r'\["(?P<s>[^"]+)",\s*"(?P<col>[^"]*)",\s*"(?P<en>[^"]*)",\s*"(?P<cn>[^"]*)",\s*"(?P<deg>[^"]*)",\s*"(?P<url>[^"]*)",\s*"(?P<disc>[^"]*)",\s*"(?P<det>[^"]*)"\]')
rows=[m.groupdict() for m in pat.finditer(r[c0:c1])]
# PROGRAMS 对象计数
p0=r.index("const PROGRAMS=["); p1=r.index("const CATD=[")
progs=re.findall(r'\{id:', r[p0:p1])
# SCHOOLS
s0=r.index("const SCHOOLS=["); s1=r.index("const PROGRAMS=")
schools=re.findall(r'\{id:"', r[s0:s1])

dead=[g["det"] for g in rows if not os.path.exists(os.path.join(base,g["det"]))]
resid=[g for g in rows if re.search(r"\bMBA\b|Master of Business Administration|Nurse|\bMSN\b|DNP|DNAP|Physician Assistant|Physical Therapy|Occupational Therapy|Speech-Language|Dentistry|Veterinary|Genetic Counsel|Juris Doctor|Medical Doctor", g["en"]+" "+g["deg"]+" "+g["cn"], re.I)]
from collections import Counter
print("院校:", len(schools), " 核验PROGRAMS:", len(progs), " 目录CATD:", len(rows))
print("死链:", len(dead), dead[:5])
print("残留排除项:", len(resid), [g["cn"] for g in resid][:10])
print("按校:", dict(Counter(g["s"] for g in rows)))
