# -*- coding: utf-8 -*-
import io,sys,ssl,urllib.request,re
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
base="https://harris.uchicago.edu"
def get(p):
    req=urllib.request.Request(base+p,headers={"User-Agent":"Mozilla/5.0"})
    with urllib.request.urlopen(req,timeout=25,context=ctx) as r:
        return r.status,r.read().decode("utf-8","replace")
def clean(h):
    t=re.sub(r"<script[\s\S]*?</script>","",h)
    t=re.sub(r"<style[\s\S]*?</style>","",t)
    t=re.sub(r"<[^>]+>"," ",t); return re.sub(r"\s+"," ",t)
for p in ["/admissions/applying-to-harris/international-students/application-details",
          "/admissions/applying-to-harris/international-students",
          "/admissions/applying-to-harris/FAQ"]:
    try:
        st,h=get(p); t=clean(h)
        print("\n====",p,st,"len",len(t))
        for kw in ["TOEFL","IELTS","score","100","90","7.0","6.5","overall","minimum","sub-score","waiver"]:
            m=re.search(re.escape(kw),t)
            if m:
                a=max(0,m.start()-120); b=min(len(t),m.end()+220)
                print(" -",kw,"…",t[a:b].strip()[:320])
    except Exception as e:
        print("====",p,"ERR",repr(e))
