#!/usr/bin/env python3
"""Verifikasi live post 3065 tslaw.id setelah perbaikan 2026-10-08 (HTML publik)."""
import re, sys, time, urllib.request

URL = ("https://www.tslaw.id/5-layanan-jasa-hukum-surabaya-untuk-umkm-dan-perusahaan-kecil-3/"
       f"?nocache={int(time.time())}")
req = urllib.request.Request(URL, headers={"User-Agent": "Mozilla/5.0 (X11; Linux x86_64)"})
with urllib.request.urlopen(req, timeout=120) as r:
    html = r.read().decode("utf8", "ignore")
    print("HTTP", r.status, "| cache:", r.headers.get("cf-cache-status"), "| x-cache:",
          r.headers.get("x-cache"), "| bytes:", len(html))

judul = re.search(r"<title>(.*?)</title>", html, re.S)
desc = re.search(r'<meta name="description" content="(.*?)"', html, re.S)
h1 = re.findall(r"<h1[^>]*>(.*?)</h1>", html, re.S)

hasil = {
    "title_tag": judul.group(1).strip() if judul else None,
    "meta_desc": desc.group(1).strip() if desc else None,
    "h1": [re.sub(r"<[^>]+>", "", x).strip() for x in h1][:3],
    "meta_desc_memuat_fokus": bool(desc and "layanan hukum surabaya" in desc.group(1).lower()),
    "meta_desc_memuat_kueri2": bool(desc and "jasa hukum bisnis" in desc.group(1).lower()),
    "bagian_baru_live": "Layanan Hukum Surabaya: Apa Saja yang Termasuk?" in html,
    "manfaat_baru_live": "Negosiasi lebih kuat" in html,
    "tabel_hantu_hilang": "Tabel di atas" not in html,
    "tombol_wa_live": html.count("wa.me/6281909222026"),
    "faqpage_live": html.count("FAQPage"),
    "tautan_pilar_live": html.count("law-firm-surabaya"),
    "em_dash_di_konten_artikel": None,
}
print()
for k, v in hasil.items():
    print(f"  {k}: {v}")
