# -*- coding: utf-8 -*-
import ssl,urllib.request,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
def get(u):
    req=urllib.request.Request(u,headers={"User-Agent":"Mozilla/5.0"})
    with urllib.request.urlopen(req,context=ctx,timeout=20) as r:
        return r.read().decode("utf-8","ignore")
for u in [
 "https://dmi.duke.edu/education/core-courses",
 "https://dmi.duke.edu/education/what-our-former-students-say-and-now-do",
 "https://dmi.duke.edu/degrees/core-courses",
 "https://dmi.duke.edu/degrees/what-our-students-say",
]:
    try:
        t=get(u)
        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"\s+"," ",txt).strip()
        print("URL",u,"HTML",len(t),"TXT",len(txt))
        print(txt[:1800])
        print("="*80)
    except Exception as e:
        print("URL",u,"ERR",repr(e)); print("="*80)
