# -*- 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
urls={
 "uw-meng-ece":"https://uwaterloo.ca/future-graduate-students/programs/by-faculty/engineering/electrical-and-computer-engineering-master-engineering-meng",
 "notre-mscse":"https://graduateschool.nd.edu/degree-programs/computer-science-and-engineering-mscse---masters-professional/",
 "notre-acms":"https://graduateschool.nd.edu/degree-programs/applied-and-computational-mathematics-and-statistics-ms---masters-professional/",
 "notre-ds":"https://graduateschool.nd.edu/degree-programs/data-science-ms---masters-professional/",
}
for k,u in urls.items():
    try:
        req=urllib.request.Request(u,headers={"User-Agent":"Mozilla/5.0"})
        html=urllib.request.urlopen(req,timeout=20,context=ctx).read().decode("utf-8","ignore")
        txt=re.sub(r"<script.*?</script>","",html,flags=re.S)
        txt=re.sub(r"<style.*?</style>","",txt,flags=re.S)
        txt=re.sub(r"<[^>]+>"," ",txt)
        txt=re.sub(r"\s+"," ",txt).strip()
        print("="*8,k,"LEN",len(html),"TEXT",len(txt))
        print(txt[:600])
        print()
    except Exception as e:
        print("="*8,k,"ERR",repr(e))
