# -*- coding: utf-8 -*-
import re, sys, io, urllib.request, ssl
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
hdr={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"}
def fetch(u):
    req=urllib.request.Request(u, headers=hdr)
    with urllib.request.urlopen(req, timeout=15, context=ctx) as r:
        return r.read(300000).decode("utf-8","ignore")

u="https://catalog.unc.edu/graduate/schools-departments/computer-science/"
body=fetch(u)
body=re.sub(r'<script[\s\S]*?</script>',' ',body,flags=re.I)
body=re.sub(r'<style[\s\S]*?</style>',' ',body,flags=re.I)
body=re.sub(r'<[^>]+>',' ',body)
body=re.sub(r'&nbsp;',' ',body); body=re.sub(r'&#039;',"'",body)
body=re.sub(r'\s+',' ',body)
for m in re.finditer(r'GRE', body):
    a=max(0,m.start()-260); b=min(len(body),m.end()+260)
    print("...", body[a:b], "...")
    print("-----")
