# -*- coding: utf-8 -*-
import urllib.request, ssl, sys, io, re, json, os
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")
SCTX = ssl.create_default_context(); SCTX.check_hostname=False; SCTX.verify_mode=ssl.CERT_NONE
UA = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"}
def get(url):
    req = urllib.request.Request(url, headers=UA)
    return urllib.request.urlopen(req, timeout=20, context=SCTX).read().decode("utf-8","ignore")
def strip(h):
    h = re.sub(r"<script[\s\S]*?</script>", " ", h, flags=re.I)
    h = re.sub(r"<style[\s\S]*?</style>", " ", h, flags=re.I)
    h = re.sub(r"<[^>]+>", " ", h); h = re.sub(r"\s+"," ", h)
    return h.strip()
url = "https://bulletins.nyu.edu/graduate/arts-science/programs/comparative-literature-ma/"
text = strip(get(url))
print("len=", len(text))
for kw in ["Master of Arts", "Program Requirements", "credit", "thesis", "exam", "language", "course", "Admission", "Elective"]:
    i = text.lower().find(kw.lower())
    if i>=0:
        print(f"\n[{kw}] ...{text[max(0,i-80):i+400]}...")
