Skip to main content
  • From Page or Locator
  • From Content
export declare function extractStructuredData(options: {
  source: Page | Locator;
  dataSchema: JsonSchema | z.ZodSchema;
  prompt?: string;
  strategy?: "IMAGE" | "MARKDOWN" | "HTML";
  enableDomMatching?: boolean;
  enableCache?: boolean;
  maxRetries?: number;
  model?: SUPPORTED_MODELS;
  apiKey?: string;
}): Promise<any>;
Extract structured data from web pages using AI-powered content analysis.

Examples

import { extractStructuredData } from '@intuned/browser/ai';
export default async function handler(params, page, context){
await page.goto("https://books.toscrape.com/")
const product = await extractStructuredData({
  source: page,
  strategy: "HTML",
  model: "gpt-4o",
  dataSchema: {
    type: "object",
    properties: {
      name: { type: "string" },
      price: { type: "string" },
      description: { type: "string" },
      inStock: { type: "boolean" }
    },
    required: ["name", "price"]
  },
  prompt: "Extract product details from this e page"
});
console.log(`Found book: ${product.name} - ${product.price}`);
}

Arguments

options
Object
required
Configuration object containing extraction parameters

Returns: any

Promise resolving to the extracted structured data matching the provided schema