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
B="https://www.biomedicalsciences.bsd.uchicago.edu"
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.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()
# discover links from root
h=get(B+"/")
links=sorted(set(re.findall(r'href="(/[^"]*)"', h)))
for x in links:
    if any(k in x.lower() for k in ["admission","tuition","curricul","faq","outcome","career","concentr","format","overview","project"]):
        print("LINK", x)
print("="*40)
for p in ["/admissions/","/tuition-and-fees/","/curriculum/","/faq/","/outcomes/","/career-opportunities/"]:
    u=B+p
    try:
        t=clean(get(u))
        print("\n####",p,"\n",t[:1700])
    except Exception as e:
        print("\nERR",p,repr(e)[:100])
