# -*- 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
base="https://www.rotman.utoronto.ca"
def txt(u):
    req=urllib.request.Request(u,headers={"User-Agent":"Mozilla/5.0"})
    h=urllib.request.urlopen(req,timeout=25,context=ctx).read().decode("utf-8","ignore")
    t=re.sub(r"<script.*?</script>","",h,flags=re.S); t=re.sub(r"<style.*?</style>","",t,flags=re.S)
    t=re.sub(r"<[^>]+>"," ",t); t=re.sub(r"\s+"," ",t).strip()
    return t
for p in ["/programs/specialized-programs/master-of-finance/admissions/","/programs/specialized-programs/master-of-finance/tuition-and-scholarships/"]:
    t=txt(base+p)
    print("\n########",p,"len",len(t))
    for kw in ["deadline","Deadline","TOEFL","IELTS","Duolingo","GPA","B average","work experience","years’ experience","year experience","online","part-time","full-time","in-person","tuition fee","$","scholarship","GMAT","GRE","prerequisite","recommend"]:
        i=t.lower().find(kw.lower())
        if i>=0: print("\n["+kw+"]",t[max(0,i-70):i+190])
