# -*- coding: utf-8 -*-
import io, sys, urllib.request, ssl, re, os
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 fetch(url):
    req=urllib.request.Request(url, headers={"User-Agent":"Mozilla/5.0"})
    r=urllib.request.urlopen(req, timeout=15, context=ctx)
    return r.read().decode("utf-8","ignore")

body = fetch("https://catalog.unc.edu/graduate/degree-programs/")
# extract all dept links
links = re.findall(r'href="(/graduate/schools-departments/[^"]+)"', body)
uniq = sorted(set(links))
for l in uniq:
    print(l)
