Skip to main content
Version: Next

ExtractFunction

The extract helper exposed on PydanticAiCrawlingContext.

Binds the configured extractor to the current page, so a handler passes just the schema and the optional per-call knobs.

Index

Methods

Methods

__call__

  • async __call__(schema, *, scope, cache_tag, additional_instructions): TSchema
  • Extract an instance of schema from the current page.


    Parameters

    • schema: type[TSchema]

      The Pydantic model describing the desired output.

    • optionalkeyword-onlyscope: str | None = None

      Optional CSS selector restricting extraction to the first matching subtree. Saves tokens and prevents matches outside the region of interest.

    • optionalkeyword-onlycache_tag: str | None = None

      Optional tag used by caching extractors to bucket cached selectors per page kind. Defaults to context.request.label. Unlabeled requests share one bucket, which overflows fast when page kinds differ.

    • optionalkeyword-onlyadditional_instructions: str | None = None

      Extra instructions appended to the base instructions for this call only (e.g. 'the price is the discounted one, not the list price'). Does not replace the base instructions.

    Returns TSchema

Page Options