Skip to content

API Reference parrot_tools.scraping.extraction_models

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

parrot_tools.scraping.extraction_models

View source

ExtractionPlan Data Models.

Pydantic v2 models for schema-driven extraction: what to extract (entities, fields, selectors) and result containers for extracted data.

ExtractionPlan is a richer cousin of ScrapingPlan — it describes WHAT to extract (entity types, field specs) rather than HOW to navigate (steps).

Class EntityFieldSpec

Specification for a single field within an entity.

Fields:

Field Type Default Description
name str
description str
field_type Literal['text', 'number', 'currency', 'url', 'boolean', 'list'] 'text'
required bool True
selector Optional[str] None
selector_type Literal['css', 'xpath'] 'css'
extract_from Literal['text', 'attribute', 'html'] 'text'
attribute Optional[str] None

Class EntitySpec

Specification for one type of entity to extract.

Fields:

Field Type Default Description
entity_type str
description str
fields List[EntityFieldSpec]
repeating bool True
container_selector Optional[str] None
container_selector_type Literal['css', 'xpath'] 'css'

Class ExtractedEntity

A single structured entity extracted from a page.

Fields:

Field Type Default Description
entity_type str
fields Dict[str, Any]
source_url str
confidence float 0.0
raw_text Optional[str] None
rag_text str ''

Class ExtractionPlan

Rich schema describing WHAT to extract — translates to ScrapingPlan for execution.

Auto-populates domain, name, fingerprint, and created_at from the URL in model_post_init, matching the behaviour of ScrapingPlan.

Fields:

Field Type Default Description
name Optional[str] None
url str
domain str ''
objective str
fingerprint str ''
entities List[EntitySpec]
ignore_sections List[str]
page_category str ''
extraction_strategy Literal['hybrid', 'selector', 'llm'] 'hybrid'
source Literal['llm', 'developer', 'user'] 'llm'
version int 1
confidence float 0.0
created_at Optional[datetime] None
last_used_at Optional[datetime] None
success_count int 0
failure_count int 0

Method ExtractionPlan.model_post_init

Auto-populate domain, name, fingerprint, and created_at from URL.

model_post_init(__context: Any) -> None

Parameter Type Default Description
__context Any

Method ExtractionPlan.to_scraping_plan

Translate entity/field specs into a ScrapingPlan for mechanical execution.

Builds navigation steps (navigate + wait) and derives selector entries from each EntityFieldSpec that has a selector defined.

to_scraping_plan() -> ScrapingPlan

Returns: ScrapingPlan — ScrapingPlan with navigate steps and selectors derived from entity definitions.

Class ExtractionResult

Complete result from an extraction run.

Fields:

Field Type Default Description
url str
objective str
entities List[ExtractedEntity]
plan_used ExtractionPlan
extraction_strategy Literal['hybrid', 'selector', 'llm']
success bool True
error_message Optional[str] None
elapsed_seconds float 0.0

Attributes:

Attribute Type Description
total_entities int Total number of entities extracted (computed from entities list).

Alias ScrapingPlan

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

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