# -*- coding: utf-8 -*-
import io, sys, os, urllib.request, ssl, 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
base="https://as.vanderbilt.edu/economics/"
for k,sub in {"vandy-maecon-adm":"ma-admissions/","vandy-maecon-deg":"ma-degree-requirements/","vandy-maecon-fin":"ma-financial-aid/","vandy-maecon-faq":"ma-faq/"}.items():
    try:
        req=urllib.request.Request(base+sub,headers={"User-Agent":"Mozilla/5.0"})
        t=urllib.request.urlopen(req,timeout=15,context=ctx).read().decode("utf-8","ignore")
        txt=html.unescape(re.sub(r"<script.*?</script>","",t,flags=re.S)); txt=re.sub(r"<style.*?</style>","",txt,flags=re.S); txt=re.sub(r"<[^>]+>"," ",txt); txt=re.sub(r"\s+"," ",txt)
        open(f"_16_{k}.txt","w",encoding="utf-8").write(txt); print(k,len(txt))
    except Exception as e:
        print(k,"ERR",type(e).__name__,getattr(e,"code",""))
