import ssl, urllib.request, re, sys, io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
ctx = ssl.create_default_context(); ctx.check_hostname=False; ctx.verify_mode=ssl.CERT_NONE
BASE="https://bmi.bsd.uchicago.edu/"
paths=["","/education/","/education/graduate","/programs/","/masters/","/graduate-program/","/programs/ms","/programs/master-science","/admissions/","/admissions/graduate"]
def get(u):
    req=urllib.request.Request(u, headers={"User-Agent":"Mozilla/5.0"})
    with urllib.request.urlopen(req, context=ctx, timeout=20) as r:
        return r.status, r.read().decode("utf-8","ignore")
for p in paths:
    u=BASE.rstrip("/")+p
    try:
        st,html=get(u)
        hrefs=sorted(set(re.findall(r'href="([^"]*(?:master|graduate|ms|program|admission|education)[^"]*)"', html, re.I)))
        print("OK", st, u, "len", len(html))
        for h in hrefs[:25]: print("   ", h)
    except Exception as e:
        print("ERR", u, repr(e)[:120])
