# -*- 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
def get(u):
    req=urllib.request.Request(u,headers={"User-Agent":"Mozilla/5.0"})
    d=urllib.request.urlopen(req,context=ctx,timeout=20).read().decode("utf-8","ignore")
    h=re.sub(r"<script.*?</script>"," ",d,flags=re.S|re.I); h=re.sub(r"<style.*?</style>"," ",h,flags=re.S|re.I)
    t=re.sub(r"<[^>]+>"," ",h); t=re.sub(r"&nbsp;|&#x27;|&amp;|&#038;"," ",t); t=re.sub(r"\s+"," ",t)
    return t

t=get("https://masters.pratt.duke.edu/apply/requirements/")
for kw in ["GRE Scores","English Language","Duolingo","recommend","Application fee","Technical Skills"]:
    i=t.find(kw)
    if i>=0: print("###",kw,"\n",t[i:i+340],"\n")
print("="*40)
t2=get("https://masters.pratt.duke.edu/admissions/tuition-financial-aid/")
for kw in ["Master of Science","MS","tuition","scholarship","Self-funded","self-funded"]:
    i=t2.find(kw)
    if i>=0: print("###",kw,"\n",t2[i:i+300],"\n")
