# -*- coding: utf-8 -*-
import io, sys, os, ssl, urllib.request, re
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")

ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE

def probe(url, timeout=12):
    try:
        req = urllib.request.Request(url, headers={"User-Agent":"Mozilla/5.0"})
        r = urllib.request.urlopen(req, timeout=timeout, context=ctx)
        b = r.read()
        return r.status, len(b), b[:400]
    except Exception as e:
        return -1, 0, str(e)[:120]

# 候选列表
cands = [
    # UT SGS 新 slug（热门：经济/CS/机械/EE/生统/流行病）
    ("UT Economics", "https://www.sgs.utoronto.ca/programs/economics/"),
    ("UT Computer Science", "https://www.sgs.utoronto.ca/programs/computer-science/"),
    ("UT Mechanical Eng", "https://www.sgs.utoronto.ca/programs/mechanical-engineering/"),
    ("UT ECE", "https://www.sgs.utoronto.ca/programs/electrical-computer-engineering/"),
    ("UT Biostatistics", "https://www.sgs.utoronto.ca/programs/biostatistics/"),
    ("UT Epidemiology", "https://www.sgs.utoronto.ca/programs/epidemiology/"),
    ("UT Management (MMM)", "https://www.sgs.utoronto.ca/programs/management/"),
    ("UT Information", "https://www.sgs.utoronto.ca/programs/information/"),
    ("UT Education", "https://www.sgs.utoronto.ca/programs/education/"),
    ("UT Nursing", "https://www.sgs.utoronto.ca/programs/nursing/"),
    ("UT Law LLM", "https://www.sgs.utoronto.ca/programs/law/"),
    # Duke MSEC
    ("Duke MSEC", "https://econ.duke.edu/masters/economics-computation/"),
    # NYU Wagner MPA 重试
    ("NYU Wagner MPA PNM", "https://bulletins.nyu.edu/public-nonprofit-management-policy-mpa/"),
    ("NYU Wagner MPA HPM", "https://bulletins.nyu.edu/health-policy-management-mpa/"),
    # JHU AAP 剩余
    ("JHU AAP Env", "https://e-catalogue.jhu.edu/arts-sciences/advanced-academic-programs/programs/environmental-sciences-policy/"),
    ("JHU AAP Energy", "https://e-catalogue.jhu.edu/arts-sciences/advanced-academic-programs/programs/energy-policy-climate/"),
]

for name, url in cands:
    s, n, _ = probe(url)
    print(f"{s:>4} {n:>7}  {name}  {url}")
