# -*- 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=[
 ("dspp-apply","https://mccourt.georgetown.edu/ms-in-data-science-for-public-policy/admissions-tuition/how-to-apply/"),
 ("dspp-intl","https://mccourt.georgetown.edu/admissions/international-applicants/"),
]
for tag,u in pages:
    try:
        req=urllib.request.Request(u,headers={"User-Agent":"Mozilla/5.0"})
        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 ["TOEFL","IELTS","Duolingo","GRE","GMAT","GPA","recommend","recommendation","Statement","resume","transcript","prerequisite","fee"]:
            i=txt.find(kw)
            if i>0: print(f"   [{kw}] …{txt[max(0,i-50):i+130]}")
    except Exception as e:
        print(tag,"ERR",type(e).__name__,str(e)[:60])
