#!/usr/bin/env python3
"""Cek schema apa yang sudah dipancarkan situs studiosoft.id (bukti nyata, bukan asumsi)."""
import json, re, urllib.request

URLS = [
    "https://studiosoft.id/riset-kompetitor-seo/",
    "https://studiosoft.id/jasa-seo-surabaya/",
]
for u in URLS:
    r = urllib.request.Request(f"{u}?cek=schema", headers={"User-Agent": "Mozilla/5.0"})
    try:
        with urllib.request.urlopen(r, timeout=60) as x:
            t = x.read().decode("utf-8", "ignore")
    except Exception as e:
        print(u, "GAGAL", e)
        continue
    blok = re.findall(r'<script[^>]*type=["\']application/ld\+json["\'][^>]*>(.*?)</script>', t, re.S)
    print(f"== {u}  ({len(blok)} blok ld+json)")
    for b in blok:
        try:
            d = json.loads(b)
        except Exception:
            print("   (tidak bisa di-parse, panjang", len(b), ")")
            continue
        def tipe(o):
            if isinstance(o, dict):
                return o.get("@type")
            if isinstance(o, list):
                return [tipe(i) for i in o]
            return None
        g = d.get("@graph") if isinstance(d, dict) else None
        if g:
            print("   graph:", [tipe(i) for i in g])
        else:
            print("   tipe:", tipe(d))
