# -*- 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)
def body(t,anchor):
    i=t.find(anchor)
    return t[i:i+3200] if i>=0 else t[:3200]
pages=[("/apply/application-requirements","Home > apply > application requirements"),
       ("/programs-of-study/macss-general-curriculum","Home > programs of study > macss general curriculum"),
       ("/apply/financial-support","Home > apply > financial support"),
       ("/apply/student-outcomes","Home > apply > student outcomes")]
for p,anc in pages:
    u="https://macss.uchicago.edu"+p
    st,h=get(u); t=clean(h)
    print("="*25,p)
    print(body(t,anc)); print()
