# -*- coding: utf-8 -*-
import io, sys, os, re, html, urllib.request, ssl
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")
ctx=ssl.create_default_context()
def fetch(url,fn):
    req=urllib.request.Request(url,headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64)"})
    b=urllib.request.urlopen(req,timeout=15,context=ctx).read()
    t=b.decode("utf-8","ignore"); open(fn,"w",encoding="utf-8").write(t)
    x=html.unescape(re.sub(r"<script.*?</script>","",t,flags=re.S)); x=html.unescape(re.sub(r"<style.*?</style>","",x,flags=re.S))
    x=re.sub(r"<[^>]+>"," ",x); return len(b),html.unescape(re.sub(r"\s+"," ",x))
base="https://as.vanderbilt.edu/biomedical-sciences/"
for sub in ["admissions","degree-requirements","aid-awards","courses","outcomes"]:
    try:
        n,x=fetch(base+sub+"/","_17_biosci-"+sub+".txt")
        print("="*12,sub,n); print(x[:1300])
    except Exception as e:
        print(sub,"ERR",type(e).__name__,str(e)[:60])
