Skip to content

API Reference parrot_tools.scraping.template_plan

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.scraping.template_plan

View source

TemplatePlan & ParamSpec — parameterized scraping plan templates.

A :class:TemplatePlan is a reusable, parameterized template that produces a concrete :class:ScrapingPlan via :meth:TemplatePlan.bind. Parameters are declared with typed :class:ParamSpec entries; {{param}} placeholders in the URL, objective, and step templates are rendered at bind time (FEAT-222, Module 1).

Rendering uses re.sub rather than str.format() so unrelated braces (CSS selectors, JSON) never raise KeyError.

Class ParamSpec

Typed parameter definition for a :class:TemplatePlan.

Fields:

Field Type Default Description
name str Parameter name, referenced as {{name}} in templates.
type Literal['string', 'int', 'date', 'enum', 'url'] 'string' One of string, int, date, enum, url.
required bool True Whether the parameter must be supplied to bind().
default Optional[Any] None Default value used when the parameter is omitted.
choices Optional[List[Any]] None Allowed values (required when type == "enum").
description str '' Human-readable description.

Alias ScrapingPlan

Re-exported from parrot_tools.scraping.plan.ScrapingPlan.

Class TemplatePlan

Parameterized plan template that produces ScrapingPlans via bind().

Fields:

Field Type Default Description
name str Template name (also used for the produced plan's fingerprint).
objective_template str Objective string with {{param}} placeholders.
url_template str Target URL with {{param}} placeholders.
params List[ParamSpec] Declared parameters.
steps_template List[Dict[str, Any]] Step dicts; string values are rendered recursively.
selectors Optional[List[Dict[str, Any]]] None Optional selector dicts (rendered recursively).
tags List[str] Tags carried into the produced plan.
browser_config Optional[Dict[str, Any]] None Optional browser configuration carried into the plan.
version str '1.0' Template version.
source str 'llm' Provenance marker ("llm" by default).
created_at datetime Creation timestamp.

Attributes:

Attribute Type Description
fingerprint str Template-level fingerprint derived from the template name.

Method TemplatePlan.bind

Bind parameters and produce a concrete :class:ScrapingPlan.

Validates kwargs against the declared :class:ParamSpec list, fills defaults for omitted optional params, renders {{param}} placeholders in the URL, objective, steps, and selectors, and returns a ScrapingPlan whose fingerprint is derived from template_name + sorted(params) (so different parameter sets never collide on the same URL fingerprint).

The rendered URL is also exposed as the implicit {{url}} placeholder available inside steps_template / selectors.

bind(**kwargs: Any) -> ScrapingPlan

Parameter Type Default Description
**kwargs Any {} Parameter values keyed by ParamSpec.name.

Returns: ScrapingPlan — A concrete ScrapingPlan.

Raises:

  • ValueError — For missing required params, type mismatches, or enum/choice violations.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally