#!/usr/bin/env python3
"""Cari cara pakai kunci Semrush bergaya 'semrtkn-...' di dokumentasi resmi mereka."""
import re, urllib.request

UA = {"User-Agent": "Mozilla/5.0"}
URL = "https://developer.semrush.com/api/v3/"
t = urllib.request.urlopen(urllib.request.Request(URL, headers=UA), timeout=90).read().decode("utf-8", "replace")
print(f"panjang dokumen: {len(t)}")

for pola in [r"semrtkn", r"A[pP]ikey", r"api\.semrush\.com[^\"'<>\s]{0,60}", r"key=[A-Za-z0-9_\-]{0,12}",
             r"Authorization[^\"'<>\n]{0,60}", r"/analytics/[a-z0-9/]*"]:
    k = re.findall(pola, t)
    unik = sorted(set(k))[:8]
    if unik:
        print(f"\n«{pola}» ({len(k)} kemunculan):")
        for u in unik:
            print("   ", u[:110])

# contoh permintaan di dokumen
contoh = re.findall(r"https://api\.semrush\.com[^\"'<>\s)]{0,140}", t)
print(f"\ncontoh URL di dokumen ({len(contoh)}):")
for c in sorted(set(contoh))[:10]:
    print("   ", c[:150])
