AI 가 쓴 Article JSON-LD 를 스크립트로 검사하기
AI 가 만든 Article JSON-LD 를 파싱하고, 권장 속성·ISO 8601 날짜·본문과의 값 일치를 스크립트로 검사해 지어낸 값을 잡는 방법입니다.
JSON-LD 는 문법이 맞아도 값이 틀릴 수 있습니다. AI 는 본문에 없는 작성자 · 이미지 · 수정 시각도 그럴듯하게 채웁니다. 파싱 → 속성 → 날짜 형식 → 본문 대조 순으로 검사하는 스크립트를 만듭니다. 메타 설명 쪽 검사는 AI 가 쓴 메타 설명을 길이·중복으로 검사하기 에 있습니다.
[1] 검사 기준부터 확인합니다. 구글 Article 구조화 데이터 문서(2026-09-08 갱신본)는 이렇게 시작합니다.
필수 속성은 없고, 권장 속성은 author(author.name · author.url) · datePublished · dateModified · headline · image 입니다. 날짜는 ISO 8601 이고, 같은 문서는 이렇게 덧붙입니다.
그래서 아래 스크립트는 속성이 빠지면 WARN, 값이 틀리면 FAIL 로 나눕니다. 이 검사를 통과해도 리치 결과가 나온다는 보장은 없습니다. 구조화 데이터는 구글이 페이지를 이해하는 데 쓰는 정보일 뿐, 노출 형태는 구글이 정합니다.
[2] 시험할 글 페이지를 만듭니다. 글과 회사는 지어낸 것이고, 일부러 <time datetime> · 작성자 링크 · og:image 를 넣었습니다. 이 값들이 JSON-LD 와 맞는지 대조할 기준입니다.
<!doctype html><html lang="ko"><head><meta charset="utf-8"><title>겨울철 베란다 토마토 키우기 | 달빛농원 블로그</title><link rel="canonical" href="https://example.com/blog/winter-balcony-tomato/"><meta property="og:image" content="https://example.com/img/winter-tomato-1200.jpg"></head><body><article><h1>겨울철 베란다에서 토마토 키우기</h1><p class="byline">글: <a rel="author" href="https://example.com/authors/a-kim/">A 작가</a></p><p>게시 <time datetime="2026-10-12T09:30:00+09:00">2026년 10월 12일</time> · 수정 <time datetime="2026-10-25T14:05:00+09:00">2026년 10월 25일</time></p><p>베란다 온도가 10도 아래로 내려가는 겨울에도 방울토마토를 키울 수 있는 조건을 정리했습니다.</p></article></body></html>[3] 프롬프트를 만들어 JSON-LD 를 받습니다. 출력은 JSON 객체 하나로 못 박고, 「없는 값은 지어내지 마세요」를 넣었습니다.
아래 HTML 은 블로그 글 한 편입니다. 이 글의 schema.org Article JSON-LD 를 만들어 주세요.- 출력은 JSON 객체 하나만. 설명·코드 펜스 금지.- 글에 있는 정보만 쓰고, 없는 값은 지어내지 마세요.$ cat prompt.1.txt page.html > in.1.txt$ claude -p --model sonnet --max-turns 1 < in.1.txt > out.1.json$ cat out.1.json{"@context":"https://schema.org","@type":"Article","headline":"겨울철 베란다에서 토마토 키우기","description":"베란다 온도가 10도 아래로 내려가는 겨울에도 방울토마토를 키울 수 있는 조건을 정리했습니다.","inLanguage":"ko","mainEntityOfPage":{"@type":"WebPage","@id":"https://example.com/blog/winter-balcony-tomato/"},"url":"https://example.com/blog/winter-balcony-tomato/","image":["https://example.com/img/winter-tomato-1200.jpg"],"author":{"@type":"Person","name":"A 작가","url":"https://example.com/authors/a-kim/"},"datePublished":"2026-10-12T09:30:00+09:00","dateModified":"2026-10-25T14:05:00+09:00"}[4] json.tool 로 파싱부터 봅니다. 문법이 틀리면 여기서 끝납니다.
$ python3 -m json.tool out.1.json > /dev/null && echo parsedparsed[5] 속성과 값을 검사하는 스크립트를 만듭니다. 파이썬 표준 라이브러리만 씁니다. 페이지에서 <h1> · <time datetime> · rel="author" 링크 · og:image 를 읽어 JSON-LD 값과 비교합니다.
#!/usr/bin/env python3"""usage: check_jsonld.py page.html jsonld.json — parse, recommended properties, ISO 8601, values vs page"""import sys, jsonfrom datetime import datetimefrom html.parser import HTMLParser class Page(HTMLParser): def __init__(s): super().__init__(); s.h1 = ""; s.h = s.a = False; s.times = []; s.authors = []; s.og = None def handle_starttag(s, t, a): a = dict(a); s.h = s.h or t == "h1" if t == "time": s.times.append(a.get("datetime")) if t == "a" and a.get("rel") == "author": s.a = True; s.authors.append(["", a.get("href")]) if t == "meta" and a.get("property") == "og:image": s.og = a.get("content") def handle_endtag(s, t): if t == "h1": s.h = False if t == "a": s.a = False def handle_data(s, d): if s.h: s.h1 += d if s.a: s.authors[-1][0] += d p = Page(); p.feed(open(sys.argv[1], encoding="utf-8").read())try: j = json.load(open(sys.argv[2], encoding="utf-8"))except json.JSONDecodeError as e: print("FAIL parse:", e); sys.exit(2)fail, warn = [], []if j.get("@type") not in ("Article", "NewsArticle", "BlogPosting"): fail.append(f"@type: {j.get('@type')!r}")warn += [f"missing {k}" for k in ("headline", "image", "author", "datePublished", "dateModified") if k not in j]if "headline" in j and j["headline"].strip() != p.h1.strip(): fail.append(f"headline differs from h1: {j['headline']!r} vs {p.h1.strip()!r}")for k in ("datePublished", "dateModified"): if k not in j: continue try: tz = datetime.fromisoformat(j[k]).tzinfo except ValueError: fail.append(f"{k} not ISO 8601: {j[k]!r}"); continue if tz is None: warn.append(f"{k} has no timezone: {j[k]!r}") if j[k] not in p.times: fail.append(f"{k} {j[k]!r} not found in page <time>: {p.times}")for x in [j["author"]] if isinstance(j.get("author"), dict) else j.get("author", []): if x.get("name") not in [n for n, _ in p.authors]: fail.append(f"author.name {x.get('name')!r} not in page byline: {[n for n, _ in p.authors]}") if x.get("url") and x["url"] not in [u for _, u in p.authors]: fail.append(f"author.url {x['url']!r} not in page")for u in [j["image"]] if isinstance(j.get("image"), str) else j.get("image", []): if u != p.og: fail.append(f"image {u!r} not the page's og:image {p.og!r}")for w in warn: print("WARN", w)for f in fail: print("FAIL", f)print(f"{len(fail)} fail, {len(warn)} warn"); sys.exit(1 if fail else 0)[6] 첫 결과를 검사합니다.
$ python3 -I check_jsonld.py page.html out.1.json; echo "exit $?"0 fail, 0 warnexit 0본문에 값이 다 있으면 AI 는 그대로 옮겼습니다. 이 실행에서는 틀린 곳이 없었습니다.
[7] 본문에 정보가 없는 페이지로 바꿉니다. 작성자 · 게시 시각 · 대표 이미지가 없고 날짜만 글자로 한 줄 있습니다. 프롬프트에서 「없는 값은 지어내지 마세요」를 빼고 「권장 속성을 모두 채워 주세요」를 넣었습니다.
<!doctype html><html lang="ko"><head><meta charset="utf-8"><title>베란다 상추 키우기 | 달빛농원 블로그</title><link rel="canonical" href="https://example.com/blog/balcony-lettuce/"></head><body><article><h1>베란다에서 상추 키우기</h1><p>화분 크기와 물 주는 간격을 정리했습니다.</p><p>2026년 10월 20일</p></article></body></html>아래 HTML 은 블로그 글 한 편입니다. 이 글의 schema.org Article JSON-LD 를 만들어 주세요. 구글 문서의 권장 속성(author, datePublished, dateModified, headline, image)을 모두 채워 주세요.- 출력은 JSON 객체 하나만. 설명·코드 펜스 금지.$ cat prompt.2.txt page2.html > in.2.txt$ claude -p --model sonnet --max-turns 1 < in.2.txt > out.2.json$ cat out.2.json{"@context":"https://schema.org","@type":"Article","headline":"베란다에서 상추 키우기","description":"화분 크기와 물 주는 간격을 정리했습니다.","image":["https://example.com/blog/balcony-lettuce/cover.jpg"],"datePublished":"2026-10-20T09:00:00+09:00","dateModified":"2026-10-20T09:00:00+09:00","author":{"@type":"Organization","name":"달빛농원","url":"https://example.com/"},"publisher":{"@type":"Organization","name":"달빛농원 블로그","url":"https://example.com/"},"mainEntityOfPage":{"@type":"WebPage","@id":"https://example.com/blog/balcony-lettuce/"},"inLanguage":"ko"}[8] 같은 스크립트로 검사합니다.
$ python3 -I check_jsonld.py page2.html out.2.json; echo "exit $?"FAIL datePublished '2026-10-20T09:00:00+09:00' not found in page <time>: []FAIL dateModified '2026-10-20T09:00:00+09:00' not found in page <time>: []FAIL author.name '달빛농원' not in page byline: []FAIL author.url 'https://example.com/' not in pageFAIL image 'https://example.com/blog/balcony-lettuce/cover.jpg' not the page's og:image None5 fail, 0 warnexit 1AI 는 페이지에 없는 이미지 주소(cover.jpg)를 만들었고, 본문에는 날짜만 있는데 09:00:00+09:00 시각을 붙였습니다. dateModified 는 수정 기록이 없는데 게시 시각을 복사했고, 작성자도 조직으로 채웠습니다. 빈칸을 채우라고 시키면 이런 값이 나옵니다. 고치는 쪽은 JSON-LD 가 아니라 페이지입니다. 실제 작성자 · 수정일 · 이미지를 본문에 넣은 뒤 다시 만들거나, 없는 속성은 빼는 쪽이 맞습니다. 구글 문서가 필수 속성을 두지 않기 때문입니다.
[9] 스크립트가 형식 오류도 잡는지, out.1.json 을 손으로 망가뜨려 확인합니다(모델이 만든 오류가 아닙니다). @type 오타와 날짜 형식을 바꾼 것이 첫 번째, 시간대를 뺀 것과 제목을 바꾼 것이 두 번째입니다.
$ python3 -I check_jsonld.py page.html bad1.json; echo "exit $?"FAIL @type: 'Artcle'FAIL datePublished not ISO 8601: '2026.10.12'2 fail, 0 warnexit 1$ python3 -I check_jsonld.py page.html bad2.json; echo "exit $?"WARN datePublished has no timezone: '2026-10-12T09:30:00'FAIL headline differs from h1: '겨울 토마토' vs '겨울철 베란다에서 토마토 키우기'FAIL datePublished '2026-10-12T09:30:00' not found in page <time>: ['2026-10-12T09:30:00+09:00', '2026-10-25T14:05:00+09:00']2 fail, 1 warnexit 1종료 코드는 FAIL 이 있으면 1, 파싱 실패는 2, 통과는 0 입니다. 빌드 스크립트에 넣을 때 그대로 씁니다.