# -*- 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
u="https://www.sgs.utoronto.ca/programs/statistics/"
req=urllib.request.Request(u,headers={"User-Agent":"Mozilla/5.0"})
t=urllib.request.urlopen(req,timeout=20,context=ctx).read().decode("utf-8","ignore")
print("len",len(t))
for kw in ["Statistics","statistic","Quick Facts","deadline","TOEFL","tuition","MSc","Master"]:
    print(kw, t.lower().count(kw.lower()))
m=re.search(r"<title>(.*?)</title>",t,flags=re.S)
print("TITLE",m.group(1).strip() if m else "-")
# links to stat dept
for h in re.findall(r'href="([^"]*statist[^"]*)"',t)[:15]:
    print("LINK",h)
