"""查 5 条候选的实际 url"""
import re
with open('index_main.html', 'r', encoding='utf-8') as f:
    html = f.read()
m = re.search(r'const PROGRAMS=(\[[\s\S]*?\]);', html)
prog_str = m.group(1)
targets = ['duke-qfe', 'jhu-finmath', 'jhu-baai-ms', 'jhu-ds-mse', 'jhu-ece-mse']
for tid in targets:
    mm = re.search(r'\{id:"' + re.escape(tid) + r'"([\s\S]*?)(?=\{id:"|,?\n\];)', prog_str)
    if mm:
        body = mm.group(1)
        url_m = re.search(r'url:"([^"]*)"', body)
        n_m = re.search(r'n:"([^"]*)"', body)
        print(f"{tid} | n={n_m.group(1) if n_m else '?'} | url={url_m.group(1) if url_m else '?'}")
    else:
        print(f"{tid} 未找到")
