# -*- coding: utf-8 -*-
import re,io,sys
sys.stdout=io.TextIOWrapper(sys.stdout.buffer,encoding="utf-8")
t=open("_duke_mems_pratt-tui.html",encoding="utf-8").read()
heads=re.findall(r'accordion__toggle"[^>]*>\s*<h3[^>]*>(.*?)</h3>',t,flags=re.S)
print("ACCORDIONS:")
for h in heads:
    h=re.sub(r"<[^>]+>"," ",h); h=re.sub(r"\s+"," ",h).strip(); print("  -",h)
# financial aid section
m=re.search(r'id="financial-aid".*?</ul>\s*</div>',t,flags=re.S)
txt=re.sub(r"<script.*?</script>","",t,flags=re.S)
# find aid text after financial-aid anchor
i=txt.find('id="financial-aid"')
seg=txt[i:i+3500] if i>0 else ""
seg=re.sub(r"<[^>]+>"," ",seg); seg=re.sub(r"\s+"," ",seg).strip()
print("\nFINANCIAL AID SEG:\n",seg[:2500])
