# -*- coding: utf-8 -*-
import io,sys,ssl,urllib.request,re,html
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
u="https://bulletin.stanford.edu/programs/MGTSC-MS"
req=urllib.request.Request(u,headers={"User-Agent":"Mozilla/5.0"})
try:
    t=urllib.request.urlopen(req,timeout=20,context=ctx).read().decode("utf-8","ignore")
except Exception as e:
    print("ERR",type(e).__name__,e); sys.exit(0)
print("LEN",len(t))
c=html.unescape(re.sub(r"\s+"," ",re.sub(r"<[^>]+>"," ",re.sub(r"<script.*?</script>"," ",t,flags=re.S))))
for kw in ["Program Overview","Requirements Overview","units","thesis","GPA","track","Concentration","Depth","Breadth","Prerequisite","background","Coterminal","Honors","Cooperative","online","part-time","Financial Assistance","fellowship","assistantship","Operations","Finance","Analytics","Decision","Coterminal Master"]:
    idxs=[m.start() for m in re.finditer(re.escape(kw),c)]
    if not idxs: print("\n["+kw+"] 未命中"); continue
    j=idxs[0]; print("\n["+kw+"]",c[max(0,j-70):j+260])
