Complete API reference for the extract() method
// With schema and options await page.extract<T extends z.AnyZodObject>(options: ExtractOptions<T>): Promise<ExtractResult<T>> // String instruction only await page.extract(instruction: string): Promise<{ extraction: string }> // No parameters (raw page content) await page.extract(): Promise<{ page_text: string }>
interface ExtractOptions<T extends z.AnyZodObject> { instruction?: string; schema?: T; modelName?: AvailableModel; modelClientOptions?: ClientOptions; domSettleTimeoutMs?: number; selector?: string; iframes?: boolean; } type ExtractResult<T> = z.infer<T>;
true
false
30000
Promise<ExtractResult<T>>
import { z } from 'zod'; // Schema definition const ProductSchema = z.object({ name: z.string(), price: z.number(), inStock: z.boolean() }); // Extraction const product = await page.extract({ instruction: "extract product details", schema: ProductSchema });
{ "name": "Product Name", "price": 100, "inStock": true }