# -*- coding: utf-8 -*-
import re,io,sys
sys.stdout=io.TextIOWrapper(sys.stdout.buffer,encoding="utf-8")
def load(f):
    t=open(f,encoding="utf-8").read()
    t=re.sub(r"<script.*?</script>","",t,flags=re.S); t=re.sub(r"<style.*?</style>","",t,flags=re.S)
    t=re.sub(r"<[^>]+>"," ",t); return re.sub(r"\s+"," ",t).strip()
req=load("_duke_mems_pratt-req.html")
deg=load("_duke_mems_pratt-deg.html")
tui=load("_duke_mems_pratt-tui.html")
def show(name,t,kws,win=350):
    print("########",name)
    for kw in kws:
        for m in re.finditer(re.escape(kw),t,re.I):
            a=max(0,m.start()-win); b=min(len(t),m.end()+win)
            print("----",kw); print(t[a:b]); break
show("REQ",req,["English Language Testing","TOEFL","Duolingo","Minimum Application Requirements","Application Fee","Master of Science","GRE Scores"])
print()
show("DEG",deg,["Master of Science","credits","thesis","Research"])
print()
show("TUI",tui,["Master of Science","$","per semester","self-funded","scholarship"])
