# -*- coding: utf-8 -*-
import sys, io, re, pathlib, requests, html as H
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
CACHE = pathlib.Path(r"D:\work buddy\2026-11-05-14-15-52\cache")
UA = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0 Safari/537.36"}

def strip(t):
    t = re.sub(r"<script.*?</script>", " ", t, flags=re.S|re.I)
    t = re.sub(r"<style.*?</style>", " ", t, flags=re.S|re.I)
    t = re.sub(r"<br\s*/?>", "\n", t, flags=re.I)
    t = re.sub(r"</(p|div|li|tr|h\d|td|th)>", "\n", t, flags=re.I)
    t = re.sub(r"<[^>]+>", " ", t)
    t = H.unescape(t)
    t = re.sub(r"[ \t]+", " ", t)
    t = re.sub(r"\n\s*\n+", "\n", t)
    return t.strip()

for name, u in [("bursar-fall26", "https://www.bursar.gatech.edu/Fall_2026")]:
    r = requests.get(u, headers=UA, timeout=25)
    (CACHE / (name + ".html")).write_text(r.text, encoding="utf-8", errors="ignore")
    t = strip(r.text)
    print(name, r.status_code, len(t))
    i = t.find("Tuition")
    print(t[:400].replace("\n", " | "))
    money = [m for m in re.findall(r"\$[0-9][0-9,\.]*", t)]
    print("MONEY count", len(money), money[:40])
    j = t.find("Graduate")
    print(t[j:j+2500] if j > 0 else "")
