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()
h=get(B+"/")
print("ALL LINKS:")
for x in sorted(set(re.findall(r'href="([^"]*)"', h))):
    if any(k in x.lower() for k in ["tuition","fee","english","financial","cost","faq","admission"]):
        print("  ",x)
for p in ["/admissions/","/faq/"]:
    t=clean(get(B+p))
    print("\n####",p,"len",len(t))
    print(t[1500:4200])
