#!/usr/bin/env python3
"""Cek detail halaman #3770 di live: blok schema FAQPage & tag meta description."""
import json, re, time, urllib.request

U = "https://studiosoft.id/jasa-pembuatan-website-profesional-untuk-usaha-jasa-di-surabaya/"
r = urllib.request.Request(U + "?nc=" + str(int(time.time())), headers={"User-Agent": "Mozilla/5.0", "Cache-Control": "no-cache"})
h = urllib.request.urlopen(r, timeout=90).read().decode("utf-8", "replace")

blocks = re.findall(r'<script[^>]*application/ld\+json[^>]*>(.*?)</script>', h, re.S)
print(f"total blok ld+json: {len(blocks)}")
for i, b in enumerate(blocks):
    tipe = sorted(set(re.findall(r'"@type":"?([A-Za-z\[\"]+)', b)))
    print(f"  blok {i+1}: {len(b)} char | tipe: {tipe[:6]} | ada FAQPage: {'FAQPage' in b}")
    if "FAQPage" in b and len(b) < 4000:
        try:
            d = json.loads(b)
            print("      jumlah mainEntity:", len(d.get("mainEntity", [])), "| @id:", d.get("@id"))
        except Exception as e:
            print("      parse gagal:", str(e)[:80])

print("\n=== tag description ===")
for m in re.findall(r'<meta[^>]*name=[\'"]description[\'"][^>]*>', h, re.I):
    print(" ", m[:200])
print("\n=== og:description ===")
for m in re.findall(r'<meta[^>]*property=[\'"]og:description[\'"][^>]*>', h, re.I):
    print(" ", m[:180])
