import re, json, io, sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
html = open('index_main.html', encoding='utf-8').read()
m = re.search(r'const PROGRAMS\s*=\s*\[(.*?)\];', html, re.S)
body = m.group(1)
blocks = re.findall(r'\{id:"([^"]+)"([\s\S]*?)(?=\{id:"|$)', body)
phd=ms=other=0
lvl_missing=[]
for i,(bid, rest) in enumerate(blocks):
    lm = re.search(r'lvl:"([^"]*)"', rest)
    lvl = lm.group(1) if lm else ''
    if lvl=='d': phd+=1
    elif lvl=='m': ms+=1
    else: other+=1; lvl_missing.append(bid)
print('PROGRAMS total:', len(blocks))
print('phd(lvl d):', phd, 'master(lvl m):', ms, 'other/missing:', other)
print('missing lvl sample:', lvl_missing[:10])
# 全英文 n 候选扫描
en_only=[]
for bid, rest in blocks:
    nm = re.search(r'n:"([^"]*)"', rest)
    en = re.search(r'en:"([^"]*)"', rest)
    n = nm.group(1) if nm else ''
    if n and re.fullmatch(r'[A-Za-z0-9\s\-\&\(\)\.,/\'’·]+', n.strip()):
        en_only.append((bid, n.strip(), en.group(1) if en else ''))
print('全英文 n 条数:', len(en_only))
for x in en_only[:60]:
    print(x[0], '|', x[1])
