Skip to main content

Internal Service: scrape_ai_site

Fetches the llms.txt file from our deployed AI-optimized site. For product-specific AI articles, also fetches the dedicated product llms file.

Function Signature

Parameters

Returns

Scalable Product LLMs Architecture

For sites with many products (up to 5,000+), we use a scalable file structure:

For Business AI Articles:

  • Fetches only /llms.txt
  • Uses general business context

For Product AI Articles:

  • Fetches /llms.txt (business context)
  • Also fetches /llms/{product-slug}.txt (product details)
  • Falls back to root llms.txt if product file doesn’t exist

Behavior

  1. Strips trailing slash from deployment URL
  2. Adds Vercel bypass protection header if VERCEL_BYPASS_PROTECTION_SECRET is set
  3. Fetches /llms.txt with up to 5 retries (8 second delay between retries)
  4. If product_name is provided, also fetches /llms/{product-slug}.txt
  5. Returns the content for use in Step 3

Why This Architecture?

Benefits:
  • Constant memory - Each AI article loads ~5KB total
  • No token limits - Never hits Gemini’s context window
  • Fast - Small files = fast fetches
  • Independent - Update one product without touching others

Environment Variables

Code Location