import re, json
html = open('index_main.html', encoding='utf-8').read()
all_ids = set(re.findall(r'\{id:"([^"]+)"', html))
todo = json.load(open('todo_upgrade.json', encoding='utf-8'))

# 找所有 PhD pending
phd_todo = [t for t in todo if 'PhD' in t.get('deg','')]
print('Total PhD in todo:', len(phd_todo))

# 按学校分组
from collections import defaultdict
by_school = defaultdict(list)
for t in phd_todo:
    by_school[t.get('s','?')].append(t)

# 重点学校：jhu, nyu, col, yale, princeton, harvard, mit, uchicago, berkeley, ucla, ucsd
for sch in ['jhu','nyu','col','yale','princeton','harvard','mit','uchicago','berkeley','ucla','ucsd','usc','gatech','umich','unc','cornell','brown','emory','vanderbilt','notre','wustl','geo','duke','dartmouth','rice','caltech','stanford','illinois','uiuc','penn','up','cmu','northwestern','nu','virginia','uva','toronto','ut','ubc','mcgill','waterloo','uw']:
    items = by_school.get(sch, [])
    if items:
        print(f'\n=== {sch} ({len(items)} PhD pending) ===')
        for t in items[:15]:
            en = t.get('en','?')
            cn = t.get('cn','?')
            # 检查是否已落库（用英文名模糊匹配）
            print(f'  {en} | {cn}')
