# -*- coding: utf-8 -*-
import io, sys, os, re, ssl, urllib.request, html as h
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")

ctx = ssl.create_default_context(); ctx.check_hostname=False; ctx.verify_mode=ssl.CERT_NONE
def get(url, timeout=25):
    req = urllib.request.Request(url, headers={"User-Agent":"Mozilla/5.0"})
    r = urllib.request.urlopen(req, timeout=timeout, context=ctx)
    return r.status, r.read().decode("utf-8", errors="replace")

# Brown graduateschool 项目页
st, body = get("https://graduateschool.brown.edu/academics/degree-programs")
print("status", st, "len", len(body))
# 找项目链接
links = re.findall(r'href="(/academics/[^"]+)"[^>]*>([^<]+)</a>', body)
seen=set()
for href, t in links:
    t = h.unescape(t).strip()
    if not t or href in seen: continue
    seen.add(href)
    if any(k in t.lower() for k in ["master","m.s","m.a","sc.m","sc.m","ph.d","phd","am","sm","mcs","mpa","mph","meng"]):
        print(" ", href, "|", t[:80])
