import urllib.request
import db_upsert

conn = db_upsert.get_connection()
with conn.cursor() as cur:
    cur.execute("SELECT id FROM boards WHERE is_active = 1 LIMIT 2")
    sample_ids = [r["id"] for r in cur.fetchall()]
conn.close()

urls = [
    "/",
    "/new/",
    "/shortboard/",
    "/mid-length/",
    "/longboard/",
    "/channel-islands/",
    "/lost/",
    "/firewire/",
    "/channel-islands/ci-performance/ci-pro/",
    f"/item/{sample_ids[0]}",
    "/sell.php",
    "/sell.php?type=shop",
    "/c2c_auth.php",
    "/audit_counts.php",
    "/sitemap.xml",
    "/sitemap-categories.xml",
    "/llms.txt",
    "/robots.txt",
    "/google94ae66771ef69140.html",
]

for u in urls:
    try:
        req = urllib.request.Request("https://surfboard-search.org" + u, headers={"User-Agent": "Mozilla/5.0"})
        with urllib.request.urlopen(req, timeout=15) as r:
            body = r.read().decode("utf-8", errors="ignore")
            print(f"{r.status} | {len(body):7d} bytes | https://surfboard-search.org{u}")
            if u == "/audit_counts.php":
                for line in body.splitlines():
                    if "14項目" in line or "不一致" in line or "100% 一致" in line:
                        print("  AUDIT:", line.strip())
    except Exception as e:
        print("ERR", u, e)
