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
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")
def clean(h):
    m=re.search(r'<main[^>]*>(.*?)</main>', h, re.S|re.I)
    t=m.group(1) if m else h
    t=re.sub(r'<script.*?</script>','',t,flags=re.S|re.I)
    t=re.sub(r'<style.*?</style>','',t,flags=re.S|re.I)
    t=re.sub(r'<[^>]+>',' ',t); t=re.sub(r'\s+',' ',t)
    return t.strip()
for u in ["https://www.biomedicalsciences.bsd.uchicago.edu/","https://biomedicalsciences.uchicago.edu/"]:
    try:
        st,h=get(u)
        print("="*25,u,"OK",st,"len",len(h))
        print(clean(h)[:1800])
        print("--- hrefs ---")
        for x in sorted(set(re.findall(r'href="([^"]*)"', h))):
            if any(k in x.lower() for k in ["master","ms","program","degree","admission","phd","graduate","curricul"]):
                print("  ",x)
    except Exception as e:
        print("ERR",u,repr(e)[:120])
