const item = await page.extract({
    instruction: "extract the price of the item",
    schema: z.object({
      price: z.number(),
    }),
  });

  const price = item.price; // `item` has schema { price: number }

extract() grabs structured text from the current page using zod. Given instructions and schema, you will receive structured data.

Arguments: ExtractOptions<T extends z.AnyZodObject>

instruction
string
required

Provides instructions for extraction

schema
z.AnyZodObject
required

Defines the structure of the data to extract

modelName
AvailableModel

Specifies the model to use

modelClientOptions
object

Configuration options for the model client. See ClientOptions.

domSettleTimeoutMs
number

Timeout in milliseconds for waiting for the DOM to settle

Returns: Promise<ExtractResult<T extends z.AnyZodObject>>

Resolves to the structured data as defined by the provided schema.