Skip to content

API Reference parrot_tools.scraping.link_discoverer

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

parrot_tools.scraping.link_discoverer

View source

Link discovery for the CrawlEngine.

Extracts and filters links from HTML content, applying domain scoping, URL pattern filtering, and depth guards before returning normalized URLs.

Class LinkDiscoverer

Discovers and filters links from HTML pages.

Extracts URLs from HTML elements matching a CSS selector, normalizes them, and applies domain scoping and regex pattern filters.

Parameter Type Default Description
follow_selector str 'a[href]' CSS selector for elements to extract links from.
follow_pattern Optional[str] None Optional regex pattern; only URLs matching it are kept.
base_domain Optional[str] None If set, restricts discovered URLs to this domain (unless allow_external is True).
allow_external bool False When False (default), URLs outside base_domain are discarded.

Attributes:

Attribute Type Description
follow_pattern Optional[re.Pattern[str]]

Method LinkDiscoverer.discover

Extract, normalize, and filter links from html.

discover(html: str, base_url: str, current_depth: int, max_depth: int) -> List[str]

Parameter Type Default Description
html str Raw HTML content to parse.
base_url str The URL of the page being parsed (used for resolving relative links).
current_depth int Current crawl depth.
max_depth int Maximum allowed depth. If current_depth >= max_depth no links are returned.

Returns: List[str] — A deduplicated list of normalized URLs that pass all filters.

Alias normalize_url

Re-exported from parrot_tools.scraping.url_utils.normalize_url.

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