# -*- coding: utf-8 -*-
import urllib.request, ssl, re, sys, io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
ctx = ssl.create_default_context(); ctx.check_hostname=False; ctx.verify_mode=ssl.CERT_NONE

# CEE 列表页
url = "https://cee.rice.edu/graduate-programs"
req = urllib.request.Request(url, headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0 Safari/537.36"})
b = urllib.request.urlopen(req, timeout=15, context=ctx).read()
t = b.decode("utf-8", errors="ignore")
# 找所有链接
links = re.findall(r'href="(/[^"]+)"', t)
print("=== CEE 站内链接（含 master/ms/graduate 关键词） ===")
for l in links:
    if re.search(r'master|ms|graduate|phd|doctor', l, re.I):
        print(l)
print()
# 也找外部链接
ext = re.findall(r'href="(https?://[^"]+)"', t)
print("=== CEE 外部链接（含 rice.edu 子域） ===")
for l in ext:
    if "rice.edu" in l and re.search(r'master|ms|graduate|admissions', l, re.I):
        print(l)
