# -*- coding: utf-8 -*-
import os, re, sys, hashlib
base = r"D:\work buddy\2026-11-05-14-15-52"
cache = os.path.join(base, "cache")
u = sys.argv[1]
pats = [p.lower() for p in sys.argv[2:]] or [""]
key = "r349-" + re.sub(r'[^A-Za-z0-9]+', '-', u.replace("https://", "").replace("http://", ""))[:60] + "-" + hashlib.md5(u.encode()).hexdigest()[:6]
p = os.path.join(cache, key + ".html")
if not os.path.exists(p):
    print("MISS", p); sys.exit()
txt = open(p, encoding="utf-8", errors="ignore").read()
hrefs = re.findall(r'href="([^"#]+)"', txt)
seen = []
for h in hrefs:
    if any(x in h.lower() for x in pats) and h not in seen:
        seen.append(h)
for h in seen[:60]:
    print(h)
