# -*- coding: utf-8 -*-
import io, sys, os, json, urllib.request, ssl
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")
todo=json.load(open("todo_upgrade.json",encoding="utf-8"))
ctx=ssl.create_default_context(); ctx.check_hostname=False; ctx.verify_mode=ssl.CERT_NONE
for t in todo:
    if t["s"]=="dartmouth" and t["det"] in ("details/dartmouth-health-data-science.html","details/dartmouth-medical-informatics.html"):
        print(t["det"],t["url"])
        try:
            req=urllib.request.Request(t["url"],headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/120 Safari/537.36","Accept":"text/html"})
            r=urllib.request.urlopen(req,timeout=15,context=ctx); b=r.read()
            print("  ",r.status,len(b),"B")
            open("_rice12_dart.html","wb").write(b)
        except Exception as e:
            print("  ERR",type(e).__name__,getattr(e,'code',getattr(e,'errno','')))
# Duke 研究生院主站
for u in ["https://gradschool.duke.edu/","https://gradschool.duke.edu/academics/programs-degrees/quantitative-financial-economics"]:
    try:
        req=urllib.request.Request(u,headers={"User-Agent":"Mozilla/5.0","Accept":"text/html"})
        r=urllib.request.urlopen(req,timeout=15,context=ctx); print("Duke",r.status,len(r.read()),u)
    except Exception as e:
        print("Duke ERR",type(e).__name__,getattr(e,'code',getattr(e,'errno','')),u)
