# -*- coding: utf-8 -*-
import urllib.request, ssl, re, sys, io, os
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")
SCTX = ssl.create_default_context()
SCTX.check_hostname = False
SCTX.verify_mode = ssl.CERT_NONE
url = "https://catalog.upenn.edu/graduate/programs/translational-research-mstr/"
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.0.0 Safari/537.36",
    "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
    "Accept-Language":"en-US,en;q=0.9",
    "Referer":"https://catalog.upenn.edu/graduate/programs/",
})
try:
    with urllib.request.urlopen(req, context=SCTX, timeout=25) as r:
        body = r.read().decode("utf-8", errors="ignore")
    m = re.search(r"<title>([^<]+)</title>", body)
    cu = re.search(r'(\d+)\s*course\s*units', body, re.IGNORECASE)
    fmt = []
    for kw in ["online", "part-time", "working professional", "evening", "on-campus", "full-time"]:
        if re.search(kw, body, re.IGNORECASE):
            fmt.append(kw)
    print(f"translational-research-mstr: {r.status} {len(body)}B | title={re.sub(r'<[^>]+>','',m.group(1)) if m else '?'}")
    print(f"  CU: {cu.group(0) if cu else '?'} | FORMAT: {fmt}")
except Exception as e:
    print(f"ERR {repr(e)[:120]}")
