# -*- coding: utf-8 -*-
import urllib.request, ssl, re, io, sys
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
url="https://uwaterloo.ca/future-graduate-students/programs/by-faculty/engineering/civil-engineering-master-applied-science-masc"
html=urllib.request.urlopen(urllib.request.Request(url,headers={"User-Agent":"Mozilla/5.0"}),timeout=25,context=ctx).read().decode("utf-8","ignore")
txt=re.sub(r"<script[\s\S]*?</script>"," ",html)
txt=re.sub(r"<style[\s\S]*?</style>"," ",txt)
txt=re.sub(r"<[^>]+>"," ",txt)
for a,b in [("&nbsp;"," "),("&amp;","&"),("&#039;","'"),("&quot;",'"')]:
    txt=txt.replace(a,b)
txt=re.sub(r"\s+"," ",txt)
for kw in ["deadline","Deadline","February","September","January","May","78%","70%","3 years","work experience","civil","geotechnical","environmental","water","structural","transportation","construction","sustainability"]:
    i=txt.lower().find(kw.lower())
    if i>=0: print(kw,"…",txt[max(0,i-90):i+170].strip(),"\n")
