import json, base64, urllib.request

CRED = base64.b64encode(b'bambangbot:u3a1 G2pQ 3SWY f0zI OlGP YAjU').decode()
ids = [8057, 8055, 8053, 8051]

for pid in ids:
    req = urllib.request.Request(
        f"https://dasindonesia.com/wp-json/wp/v2/posts/{pid}?_fields=id,modified,title.rendered,content,meta",
        headers={"Authorization": "Basic " + CRED, "User-Agent": "Mozilla/5.0"})
    d = json.load(urllib.request.urlopen(req, timeout=60))
    c = d['content']['rendered']
    kw = d['meta'].get('_yoast_wpseo_focuskw') or ''
    print(f"ID {pid} | modified: {d['modified']}")
    print(f"   Title len: {len(d['meta'].get('_yoast_wpseo_title') or '')} | Desc len: {len(d['meta'].get('_yoast_wpseo_metadesc') or '')}")
    print(f"   Focuskw: {kw}")
    print(f"   Promo button: {'YA' if 'AMBIL PROMO SEKARANG' in c else 'TIDAK'}")
    print(f"   Promo link wa: {'YA' if 'wa.me/6285242380789' in c else 'TIDAK'}")
    print()
