# -*- 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
def get(u):
    req=urllib.request.Request(u,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 ["/programs-study/advanced-standing-track","/apply/living-in-chicago","/programs-of-study/courses"]:
    u="https://macss.uchicago.edu"+p
    try:
        st,h=get(u); t=clean(h)
        print("="*20,p,st,"len",len(h))
        for kw in ["STEM","OPT","Advanced Standing","tuition","Tuition","$","standing","eligible","credit","course"]:
            i=t.find(kw)
            if i>=0:
                print("  -",kw,"::",t[max(0,i-70):i+200].strip()[:260])
        i=t.find("Home >")
        print("  BODY:",t[i:i+700] if i>=0 else t[:700])
        print()
    except Exception as e:
        print("ERR",p,repr(e)); print()
# STEM grep across main + req + curriculum
for p in ["/","/apply/application-requirements","/programs-of-study/macss-general-curriculum"]:
    st,h=get("https://macss.uchicago.edu"+p)
    print(p,"STEM?", "STEM" in h, "OPT?", "OPT" in h)
