# -*- 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")

st, body = get("https://graduateschool.brown.edu/")
# 找所有链接，筛 academics/programs/degrees
links = re.findall(r'href="([^"]+)"[^>]*>([^<]+)</a>', body)
for href, t in links:
    t = h.unescape(t).strip()
    if any(k in href.lower() for k in ["academic","program","degree","study"]) and not href.startswith("#"):
        print(" ", href, "|", t[:70])
