import re, os, sys, io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
base = os.path.dirname(os.path.abspath(__file__))
html = open(os.path.join(base,'index_main.html'), encoding='utf-8').read()
blocks = dict(re.findall(r'\{id:"([^"]+)"([\s\S]*?)(?=\{id:"|$)', html))
def g(r,k):
    mm=re.search(k+r':"([^"]*)"',r); return mm.group(1) if mm else ''
for tid in ["duke-mqm-ba","vandy-msmp","princeton-fin-mfin","princeton-mfin","rice-eml-meml"]:
    r=blocks.get(tid)
    if not r: print(tid,"不在"); continue
    print(f"### {tid} | {g(r,'n')} | {g(r,'url')}")
    dp=os.path.join(base,'details',g(r,'url').split('/')[-1])
    if os.path.exists(dp):
        t=open(dp,encoding='utf-8').read()
        links=re.findall(r'https?://[^"\'<>\s]+',t)
        off=[u for u in links if 'file:' not in u and not u.startswith('details/') and 'fonts.g' not in u and 'fonts.gstatic' not in u and len(u)>12]
        print("  官网:", off[:3])
    print()
