#!/usr/bin/env python3
"""Cari nomor WhatsApp resmi TSLaw dan lihat bentuk tombol yang sudah dipakai di situs."""
import re, urllib.request

UA = {"User-Agent": "Mozilla/5.0"}
URL = ["https://www.tslaw.id/", "https://www.tslaw.id/kontak/", "https://www.tslaw.id/hubungi-kami/",
       "https://www.tslaw.id/biaya-jasa-law-firm-surabaya/"]

for u in URL:
    try:
        t = urllib.request.urlopen(urllib.request.Request(u, headers=UA), timeout=60).read().decode("utf-8", "replace")
    except Exception as e:
        print(f"{u}: gagal {str(e)[:40]}")
        continue
    wa = set(re.findall(r"(?:wa\.me/|api\.whatsapp\.com/send\?phone=)(\d+)", t))
    tautan = set(re.findall(r'href="(https://wa\.me/[^"]+)"', t))
    print(f"\n=== {u} ===")
    print(f"   nomor WA: {sorted(wa) if wa else 'tidak ada'}")
    for x in sorted(tautan)[:3]:
        print(f"   {x[:120]}")
    # bentuk tombol: cari tautan WA beserta kelas/gayanya
    for mo in re.finditer(r'<a[^>]+wa\.me[^>]*>(.{0,80}?)</a>', t, re.S):
        tag = mo.group(0)
        mulai = tag[:tag.find(">") + 1]
        teks = re.sub(r"\s+", " ", re.sub("<[^>]+>", " ", mo.group(1))).strip()
        print(f"   tombol: {teks[:44]!r}")
        print(f"      gaya: {mulai[:190]}")
        break
