# -*- 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()
for name in ["vandy-biosci","vandy-bme"]:
    t=open("_17_"+name+".txt",encoding="utf-8").read()
    links=sorted(set(html.unescape(x) for x in re.findall(r'href="([^"]+)"',t)))
    rel=[u for u in links if any(k in u for k in ["admission","degree","aid","course","outcome","requirement","biomedical-sciences","master","graduate","financial"]) and "vanderbilt" in u]
    print("="*12,name)
    for u in rel: print("  ",u)
# fetch mmkt admissions overview
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()
    tt=b.decode("utf-8","ignore"); open(fn,"w",encoding="utf-8").write(tt)
    x=html.unescape(re.sub(r"<script.*?</script>","",tt,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))
try:
    n,x=fetch("https://business.vanderbilt.edu/master-of-marketing/admissions/","_17_mmkt-adm.txt")
    print("="*12,"mmkt-adm",n)
    i=x.lower().find("deadline")
    print(x[max(0,i-200):i+500])
except Exception as e:
    print("mmkt-adm ERR",type(e).__name__,str(e)[:60])
