import base64, json, re, urllib.request

AUTH = base64.b64encode(b"bambangbot:q26r RePo BVy6 pwU2 F3z7 ouyl").decode()
h = {"Authorization": f"Basic {AUTH}", "User-Agent": "Mozilla/5.0"}
for q in ("core web vitals", "indexasi", "internal link", "kecepatan", "schema", "struktur url",
          "audit", "jasa seo"):
    r = urllib.request.Request(
        f"https://studiosoft.id/wp-json/wp/v2/posts?search={urllib.parse.quote(q)}&status=publish"
        f"&per_page=6&_fields=id,slug,title,date", headers=h)
    try:
        d = json.loads(urllib.request.urlopen(r, timeout=120).read())
    except Exception as e:
        print(q, "ERR", e)
        continue
    print(f"== {q}")
    for p in d:
        print(f"   #{p['id']} {p['date'][:10]} {p['slug']}  |  {p['title']['rendered'][:70]}")
