# -*- 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")
def clean(t):
    x=re.sub(r"<script.*?</script>","",t,flags=re.S); x=re.sub(r"<style.*?</style>","",x,flags=re.S)
    x=re.sub(r"<[^>]+>"," ",x); return re.sub(r"\s+"," ",x).strip()
c=get("https://dmi.duke.edu/education/core-courses")
open("_duke_mse_core.html","w",encoding="utf-8").write(c)
o=get("https://dmi.duke.edu/education/what-our-former-students-say-and-now-do")
open("_duke_mse_out.html","w",encoding="utf-8").write(o)
print("===== CORE COURSES =====")
print(clean(c)[1500:6099])
print()
print("===== OUTCOMES =====")
print(clean(o)[1100:4890])
