# -*- 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")
for kw in ["Master of Science Programs","Application Fee","$","110","100","150","120","90","TOEFL iBT","IELTS Academic","Duolingo English Test","120","100","80","7.0","waiver","Waiver"]:
    idxs=[m.start() for m in re.finditer(re.escape(kw),req,re.I)]
    if not idxs: continue
    i=idxs[0]
    print("----",kw,"@",i)
    print(req[max(0,i-200):min(len(req),i+420)]); print()
