> ## 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`](https://intunedhq.com/docs/automation-sdks/intuned-sdk/typescript/ai/functions/extractStructuredData) (TypeScript) or [`extract_structured_data`](https://intunedhq.com/docs/automation-sdks/intuned-sdk/python/ai/functions/extract_structured_data) (Python).

```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"]
```

## 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

> [card] [extractStructuredData (TypeScript)](https://intunedhq.com/docs/automation-sdks/intuned-sdk/typescript/ai/functions/extractStructuredData.md)
>
> TypeScript SDK helper for AI data extraction

> [card] [extract\_structured\_data (Python)](https://intunedhq.com/docs/automation-sdks/intuned-sdk/python/ai/functions/extract_structured_data.md)
>
> Python SDK helper for AI data extraction

> [card] [Cookbook (Python)](https://github.com/Intuned/cookbook/tree/main/python-examples/quick-recipes)
>
> Python quick recipes in the Intuned Cookbook

> [card] [Cookbook (TypeScript)](https://github.com/Intuned/cookbook/tree/main/typescript-examples/quick-recipes)
>
> TypeScript quick recipes in the Intuned Cookbook


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.