#!/usr/bin/env python3
"""DMark: lihat wujud nyata tombol kosong di halaman (dan apakah Spectra mendukung aria-label)."""
import re, urllib.request

UA = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/124.0 Safari/537.36"}
h = urllib.request.urlopen(urllib.request.Request("https://www.dmark.id/", headers=UA), timeout=90).read().decode("utf-8", "replace")
print(f"panjang halaman: {len(h):,}")

ID = ["spectra-mfw1srpg-t7yjsa", "spectra-55a08b79-2539-421d-baf2-2400de8586dc",
      "spectra-eee8456f-08be-4a12-904e-39d813954505", "spectra-17122c66-4bb4-49a8-a32e-0bc53eb06117"]
for i in ID:
    pos = h.find(i)
    print(f"\n=== {i} (posisi {pos}) ===")
    if pos > 0:
        potongan = h[max(0, pos - 300):pos + 400]
        print("   " + re.sub(r"\s+", " ", potongan)[:600])

print("\n=== apakah ada aria-label di halaman? ===")
print("   jumlah aria-label:", len(re.findall(r"aria-label", h)))
contoh = re.findall(r'<a[^>]*aria-label="[^"]*"[^>]*>', h)[:3]
for c in contoh:
    print("   ", c[:160])
