# -*- coding: utf-8 -*-
import urllib.request, ssl, io, sys, os, 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
slugs=["aerospace-engineering-ms","materials-science-engineering-ms","physics-ms","public-policy-ms","human-computer-interaction-ms"]
for s in slugs:
    url=f"https://catalog.gatech.edu/programs/{s}/"
    try:
        req=urllib.request.Request(url,headers={"User-Agent":"Mozilla/5.0"})
        r=urllib.request.urlopen(req,timeout=20,context=ctx)
        b=r.read(); txt=b.decode("utf-8","ignore")
        open(f"_49_{s}.html","w",encoding="utf-8").write(txt)
        # title
        m=re.search(r"<title>(.*?)</title>",txt,re.S)
        title=re.sub(r"\s+"," ",m.group(1)).strip() if m else ""
        print(s, r.status, len(txt), title[:80])
    except Exception as e:
        print(s,"ERR",repr(e)[:120])
