# -*- coding: utf-8 -*-
import io,sys,urllib.request,ssl,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
u="https://www.sgs.utoronto.ca/programs/computer-science/"
req=urllib.request.Request(u,headers={"User-Agent":"Mozilla/5.0"})
raw=urllib.request.urlopen(req,context=ctx,timeout=25).read().decode("utf-8","ignore")
tt=re.sub(r"<script[\s\S]*?</script>","",raw)
tt=re.sub(r"<style[\s\S]*?</style>","",tt)
tt=re.sub(r"<[^>]+>"," ",tt)
tt=re.sub(r"&nbsp;"," ",tt); tt=re.sub(r"&amp;","&",tt); tt=re.sub(r"&#8211;","-",tt); tt=re.sub(r"&#8217;","'",tt); tt=re.sub(r"\s+"," ",tt)
i=tt.find("Quick Facts")
print("=== Quick Facts 段 ===")
print(tt[i:i+1600])
print("\n=== 字段扫描 ===")
for kw in ["September","January","May","December","October","November","March","February","January","English","language","TOEFL","IELTS","Duolingo","tuition","fee","length","duration","months","one year","two year","course","credit hour","full-time","part-time","online","co-op","MScAC","supervisor","thesis"]:
    k=tt.lower().find(kw.lower())
    if k>=0: print(f"[{kw}] ...{tt[max(0,k-70):k+180]}...")
