# -*- coding: utf-8 -*-
import ssl,urllib.request,re,io,sys
sys.stdout=io.TextIOWrapper(sys.stdout.buffer,encoding="utf-8")
ctx=ssl.create_default_context(); ctx.check_hostname=False; ctx.verify_mode=ssl.CERT_NONE
def get(u):
    req=urllib.request.Request(u,headers={"User-Agent":"Mozilla/5.0"})
    try:
        with urllib.request.urlopen(req,context=ctx,timeout=15) as r:
            b=r.read(); return r.status,b.decode("utf-8","ignore")
    except Exception as e:
        return "ERR",str(e)
urls=[
 "https://mems.duke.edu/masters",
 "https://mems.duke.edu/masters/admissions",
 "https://mems.duke.edu/masters/degree-requirements",
 "https://gradschool.duke.edu/admissions/requirements/international-applicants/english-language-proficiency/",
 "https://gradschool.duke.edu/admissions/requirements/",
 "https://gradschool.duke.edu/admissions/tuition-and-fees/",
 "https://studentaccounts.duke.edu/tuition",
]
for u in urls:
    st,body=get(u)
    if st=="ERR":
        print("ERR",u,body[:80])
    else:
        txt=re.sub(r"<script.*?</script>","",body,flags=re.S); txt=re.sub(r"<style.*?</style>","",txt,flags=re.S)
        txt=re.sub(r"<[^>]+>"," ",txt); txt=re.sub(r"\s+"," ",txt).strip()
        print("OK",st,u,"html",len(body),"txt",len(txt))
