# -*- 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"})
    return urllib.request.urlopen(req,timeout=20,context=ctx).read().decode("utf-8","ignore")
def clean(t):
    t=re.sub(r"<script.*?</script>"," ",t,flags=re.S)
    t=re.sub(r"<style.*?</style>"," ",t,flags=re.S)
    t=re.sub(r"<[^>]+>"," ",t); return re.sub(r"\s+"," ",t)
P="https://datascience.uchicago.edu/education/masters-programs/masters-in-applied-artificial-intelligence/"
c=clean(get(P+"applied-ai-curriculum/"))
for anchor in ["Core Courses","Electives","Autumn 2027","Winter 2028","Spring 2028"]:
    i=c.find(anchor)
    print("="*70); print(anchor, "->", i)
    if i>=0: print(c[i:i+600])
# FAQ 背景/先修/在线段
f=clean(get(P+"aai-faqs/"))
for anchor in ["Do I need a STEM degree","Is there an online","prerequisite","Mathematics","programming"]:
    i=f.find(anchor)
    print("="*70); print(anchor,"->",i)
    if i>=0: print(f[i:i+400])
