# Paca 사이트(site/)의 전체 URL 을 IndexNow 로 검색엔진(Bing/ChatGPT Search·Naver·Yandex)에 즉시 통보한다. # 사용: ./build/indexnow-ping.ps1 [-SiteUrl https://mediabrowser.chanpaca.net] # 필요: site/sitemap.xml, site/{key}.txt (키 파일은 사이트 루트에서 공개 접근 가능해야 한다) # 참고: ChatGPT Search 인용의 87%가 Bing 인덱스에서 나오므로 IndexNow 즉시 색인은 최우선 순위 채널이다. param([string]$SiteUrl = "https://mediabrowser.chanpaca.net") $ErrorActionPreference = "Stop" $root = Split-Path -Parent $PSScriptRoot $key = "e9f2c7a4b1d8460f9c3e2a7b5d1f08c4" $keyLocation = "$SiteUrl/$key.txt" $sitemapPath = Join-Path $root "site\sitemap.xml" if (-not (Test-Path $sitemapPath)) { throw "site/sitemap.xml 이 없습니다." } # 1) sitemap.xml 에서 URL 전량 추출 [xml]$sitemap = Get-Content $sitemapPath -Raw $urls = @($sitemap.urlset.url | ForEach-Object { $_.loc } | Where-Object { $_ }) if ($urls.Count -eq 0) { throw "sitemap.xml 에서 URL 을 찾지 못했습니다." } Write-Host "IndexNow: $($urls.Count)개 URL 제출" -ForegroundColor Cyan # 2) 참여 엔진에 배치 제출 (api.indexnow.org 는 참여 엔진에 URL 을 공유한다) $endpoints = @( "https://api.indexnow.org/indexnow", "https://www.bing.com/indexnow", "https://searchadvisor.naver.com/indexnow" ) $body = @{ host = ([System.Uri]$SiteUrl).Host key = $key keyLocation = $keyLocation urlList = $urls } | ConvertTo-Json -Depth 3 foreach ($endpoint in $endpoints) { try { $resp = Invoke-WebRequest -Uri $endpoint -Method Post -ContentType "application/json; charset=utf-8" ` -Body $body -UseBasicParsing -TimeoutSec 30 Write-Host (" {0} -> {1} {2}" -f $endpoint, [int]$resp.StatusCode, $resp.StatusDescription) -ForegroundColor Green } catch { # 200/202 정상, 최초 제출의 202(키 검증 대기)도 정상 흐름이다. $code = $_.Exception.Response.StatusCode.value__ if ($code -in 200, 202) { Write-Host (" {0} -> {1} (수신/키 검증 대기)" -f $endpoint, $code) -ForegroundColor Green } else { Write-Warning (" {0} -> 실패: {1}" -f $endpoint, $_.Exception.Message) } } } Write-Host "완료: IndexNow 제출 종료" -ForegroundColor Green