# -*- 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"})
    return urllib.request.urlopen(req,context=ctx,timeout=25).read().decode("utf-8","ignore")
def strip(h):
    h=re.sub(r"<script[\s\S]*?</script>","",h); h=re.sub(r"<style[\s\S]*?</style>","",h)
    h=re.sub(r"<[^>]+>"," ",h); h=re.sub(r"[ \t]+"," ",h)
    h=re.sub(r"\n\s*\n+","\n",h); return h.strip()
for tag,u in [("GRADSCHOOL","https://gradschool.duke.edu/academics/programs-degrees/electrical-and-computer-engineering-ms/"),
               ("ECE-GRAD","https://ece.duke.edu/graduate")]:
    t=strip(get(u))
    print("="*30,tag,"len=",len(t))
    print(t[:4200])
