# -*- 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
urls=[
 "https://cs.uchicago.edu/graduate",
 "https://cs.uchicago.edu/graduate/masters",
 "https://cs.uchicago.edu/graduate/masters-program",
 "https://grad.uchicago.edu/academic-programs/computer-science",
 "https://www.cs.uchicago.edu/graduate/",
]
for u in urls:
    try:
        req=urllib.request.Request(u,headers={"User-Agent":"Mozilla/5.0"})
        r=urllib.request.urlopen(req,context=ctx,timeout=15)
        d=r.read().decode("utf-8","ignore")
        h=re.sub(r"<script.*?</script>"," ",d,flags=re.S|re.I); h=re.sub(r"<style.*?</style>"," ",h,flags=re.S|re.I)
        t=re.sub(r"<[^>]+>"," ",h); t=re.sub(r"\s+"," ",t)
        print("OK",r.status,u,"len",len(t))
        print("  ",t[:240])
    except Exception as e:
        print("FAIL",u,repr(e)[:120])
