# -*- coding: utf-8 -*-
import io, sys, os, ssl, json, urllib.request, urllib.error
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

targets=[
 ("ut-mfe","https://www.sgs.utoronto.ca/programs/financial-economics/"),
 ("ut-stat-msc","https://www.sgs.utoronto.ca/programs/statistics/"),
 ("ut-mmf","https://www.sgs.utoronto.ca/programs/mathematical-finance/"),
 ("ut-ece-masc","https://www.sgs.utoronto.ca/programs/electrical-computer-engineering/"),
 ("ut-mie-masc","https://www.sgs.utoronto.ca/programs/mechanical-industrial-engineering/"),
]
for tid,url in targets:
    try:
        req=urllib.request.Request(url,headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0 Safari/537.36"})
        r=urllib.request.urlopen(req,timeout=25,context=ctx)
        b=r.read(); code=r.status
        open(f"_36_{tid}.html","wb").write(b)
        print(tid,code,len(b),url)
    except Exception as e:
        print(tid,"ERR",type(e).__name__,str(e)[:120],url)
