# -*- 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=20):
    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://gradschool.vanderbilt.edu/academics/degree-programs.php")
# 找所有链接
links = re.findall(r'href="([^"]+)"[^>]*>([^<]+)</a>', body)
seen=set()
for href, t in links:
    t = h.unescape(t).strip()
    if not t or len(t) < 3 or href in seen: continue
    seen.add(href)
    # 筛项目相关链接
    if any(k in t.lower() for k in ["master","m.s","m.a","ph.d","phd","mph","meng","msc","sc.m","master of"]) and not href.startswith("#"):
        print(" ", href, "|", t[:90])
