# -*- coding: utf-8 -*-
import requests, re, sys, io, pathlib
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
BASE = pathlib.Path(r"D:\work buddy\2026-11-05-14-15-52"); CACHE = BASE / "cache"
H = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0 Safari/537.36",
     "Accept-Language": "en-US,en;q=0.9"}
h = (CACHE / "r346-vandy-ds2.html").read_text(encoding="utf-8", errors="ignore")
seen = set()
for m in re.finditer(r'href="([^"]+)"[^>]*>(.*?)</a>', h, re.S):
    href, nm = m.group(1), re.sub(r"<[^>]+>", "", m.group(2)).strip()
    if not nm or len(nm) > 70:
        continue
    if re.search(r"(master|ms|graduate|program|curricul|course|admission|tuition)", (href + " " + nm).lower()):
        u = href if href.startswith("http") else "https://www.vanderbilt.edu" + href
        if u in seen:
            continue
        seen.add(u)
        print(nm[:58], "->", u)
