# -*- 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")
# strip tags
txt=re.sub(r"<script.*?</script>"," ",t,flags=re.S)
txt=re.sub(r"<style.*?</style>"," ",txt,flags=re.S)
txt=re.sub(r"<[^>]+>"," ",txt)
txt=re.sub(r"&nbsp;"," ",txt); txt=re.sub(r"&amp;","&",txt); txt=re.sub(r"&#39;","'",txt)
txt=re.sub(r"[ \t]+"," ",txt)
# find block around Statistics
i=txt.lower().find("statistics")
print(txt[i-200:i+3500])
