# -*- coding: utf-8 -*-
import io, sys, os, urllib.request, ssl, socket, re, html
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(); ctx.check_hostname=False; ctx.verify_mode=ssl.CERT_NONE
socket.setdefaulttimeout(15)
pages=[
 ("geo-dspp","https://mccourt.georgetown.edu/master-of-science-in-data-science-for-public-policy/"),
 ("geo-cyber","https://scs.georgetown.edu/programs/484/master-of-professional-studies-in-cybersecurity-risk-management/"),
 ("vandy-bme","https://engineering.vanderbilt.edu/departments/biomedical-engineering/graduate-programs/"),
]
for tag,u in pages:
    try:
        req=urllib.request.Request(u,headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/120 Safari/537.36"})
        r=urllib.request.urlopen(req,context=ctx); b=r.read(); raw=b.decode("utf-8","ignore")
        txt=re.sub(r"<script[\s\S]*?</script>"," ",raw); txt=re.sub(r"<style[\s\S]*?</style>"," ",txt)
        txt=html.unescape(re.sub(r"<[^>]+>"," ",txt)); txt=re.sub(r"\s+"," ",txt).strip()
        open(f"_15_{tag}.txt","w",encoding="utf-8").write(txt)
        print(tag,r.status,len(b),"txt",len(txt))
        for kw in ["Online","online","part-time","Part-time","full-time","Full-time","credit","Credit","deadline","STEM","tuition"]:
            i=txt.find(kw)
            if i>0: print(f"   [{kw}] …{txt[max(0,i-50):i+110]}")
    except Exception as e:
        print(tag,"ERR",type(e).__name__,str(e)[:60])
