# -*- 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=[
 ("vandy-cs","https://engineering.vanderbilt.edu/departments/computer-science/graduate/"),
 ("vandy-ds","https://www.vanderbilt.edu/datascience/msprogram/"),
 ("geo-dsa","https://analytics.georgetown.edu/"),
 ("geo-hids","https://healthinformatics.georgetown.edu/"),
 ("geo-biostat-ms","https://biostatistics.georgetown.edu/ms/"),
]
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")
        open(f"_15_{tag}.html","w",encoding="utf-8").write(raw)
        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))
    except Exception as e:
        print(tag,"ERR",type(e).__name__,str(e)[:60])
