# -*- 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/CEE-MS"
t=urllib.request.urlopen(urllib.request.Request(u,headers={"User-Agent":"Mozilla/5.0"}),timeout=20,context=ctx).read().decode("utf-8","ignore")
c=html.unescape(re.sub(r"\s+"," ",re.sub(r"<[^>]+>"," ",re.sub(r"<script.*?</script>"," ",t,flags=re.S))))
for tag in ["Sustainable Design and Construction","Environmental Engineering","Structural Engineering","Mechanics & Computation"]:
    k=c.find(tag)
    print("\n=====",tag,"@",k,"=====")
    print(c[k:k+700])
print("\n===== GPA / 通用 =====")
k=c.find("GPA of 3.0")
print(c[k-200:k+400])
