> ## Documentation Index
> Fetch the complete documentation index at: https://intunedhq.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Scrape without writing selectors

## Recipe

This recipe shows how to extract structured data from web pages using AI without writing CSS or XPath selectors. Use [`extractStructuredData`](/automation-sdks/intuned-sdk/typescript/ai/functions/extractStructuredData) (TypeScript) or [`extract_structured_data`](/automation-sdks/intuned-sdk/python/ai/functions/extract_structured_data) (Python).

<CodeGroup dropdown>
  ```typescript TypeScript theme={null}
  import { BrowserContext, Page } from "playwright";
  import { extractStructuredData } from "@intuned/browser/ai";
  import { z } from "zod";

  // Define the schema for a single product
  const ProductSchema = z.object({
    name: z.string().describe("Product name"),
    price: z.string().describe("Product price"),
    stock: z.string().describe("Stock status"),
    category: z.string().describe("Product category"),
  });

  // Define the schema for the list of products
  const ProductsSchema = z.object({
    products: z.array(ProductSchema).describe("List of products from the table"),
  });

  export default async function handler(
    params: any,
    page: Page,
    context: BrowserContext
  ) {
    await page.goto("https://www.scrapingcourse.com/table-parsing");

    // Extract products using AI - no selectors needed
    const result = await extractStructuredData({
      source: page,
      dataSchema: ProductsSchema,
      prompt: "Extract all products from the table",
    });

    console.log(`Extracted ${result.products.length} products`);
    return result.products;
  }
  ```

  ```python Python theme={null}
  from playwright.async_api import Page
  from pydantic import BaseModel, Field
  from intuned_browser.ai import extract_structured_data
  from typing import Any, Dict, List


  class Product(BaseModel):
      """Schema for a single product."""
      name: str = Field(description="Product name")
      price: str = Field(description="Product price")
      stock: str = Field(description="Stock status")
      category: str = Field(description="Product category")


  class Products(BaseModel):
      """Schema for the list of products."""
      products: List[Product] = Field(description="List of products from the table")


  async def automation(page: Page, params: Dict[str, Any] = None, **_kwargs):
      await page.goto("https://www.scrapingcourse.com/table-parsing")

      # Extract products using AI - no selectors needed
      result = await extract_structured_data(
          source=page,
          data_schema=Products,
          prompt="Extract all products from the table",
      )

      print(f"Extracted {len(result['products'])} products")
      return result["products"]
  ```
</CodeGroup>

## How it works

1. **Define a schema** - Use Zod (TypeScript) or Pydantic (Python) to describe the data structure you want to extract
2. **Call the AI extractor** - Pass the page and schema to `extractStructuredData` / `extract_structured_data`
3. **Get structured data** - The AI analyzes the page and returns data matching your schema

No need to inspect the DOM, write selectors, or handle edge cases—the AI handles it all.

## Related SDK methods

<CardGroup cols={2}>
  <Card title="extractStructuredData (TypeScript)" icon="js" href="/automation-sdks/intuned-sdk/typescript/ai/functions/extractStructuredData">
    TypeScript SDK helper for AI data extraction
  </Card>

  <Card title="extract_structured_data (Python)" icon="python" href="/automation-sdks/intuned-sdk/python/ai/functions/extract_structured_data">
    Python SDK helper for AI data extraction
  </Card>

  <Card title="Cookbook (Python)" icon="github" href="https://github.com/Intuned/cookbook/tree/main/python-examples/quick-recipes">
    Python quick recipes in the Intuned Cookbook
  </Card>

  <Card title="Cookbook (TypeScript)" icon="github" href="https://github.com/Intuned/cookbook/tree/main/typescript-examples/quick-recipes">
    TypeScript quick recipes in the Intuned Cookbook
  </Card>
</CardGroup>
