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

# GaTech catalog 索引页找热门硕士
urls = [
  ("gatech-cs-ms", "https://catalog.gatech.edu/programs/computer-science-ms/"),
  ("gatech-ece-ms", "https://catalog.gatech.edu/programs/electrical-computer-engineering-ms/"),
  ("gatech-ml-ms", "https://catalog.gatech.edu/programs/machine-learning-ms/"),
  ("gatech-cyber-ms", "https://catalog.gatech.edu/programs/cybersecurity-ms/"),
  ("gatech-analytics-ms", "https://catalog.gatech.edu/programs/analytics-ms/"),
]
for name, url in urls:
    try:
        req = urllib.request.Request(url, headers={"User-Agent":"Mozilla/5.0"})
        r = urllib.request.urlopen(req, timeout=20, context=ctx)
        b = r.read()
        open(f"_45_{name}.html","wb").write(b)
        print(f"{name} OK {r.status} {len(b)}")
    except urllib.error.HTTPError as e:
        print(f"{name} HTTP {e.code} {url}")
    except Exception as e:
        print(f"{name} FAIL {type(e).__name__} {e}")
