Skip to content

API Reference parrot_tools.rss.fetcher

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

parrot_tools.rss.fetcher

View source

Article and feed fetching for the RSS Feed Reader Toolkit.

Strategy: fast aiohttp GET first; fall back to a shared headless Selenium driver (reusing parrot_tools.scraping.driver.SeleniumSetup, available via the scraping extra) when the response fails or looks like a JS-rendered shell. Feed XML parsing (feedparser) and all Selenium calls are blocking and run off the event loop via asyncio.to_thread / run_in_executor.

Class ArticleFetcher

Fetches feed XML and article pages with bounded concurrency.

Parameter Type Default Description
session aiohttp.ClientSession Shared aiohttp client session.
http_semaphore asyncio.Semaphore Bounds concurrent aiohttp requests (feeds + pages).
browser_semaphore asyncio.Semaphore Bounds concurrent Selenium fetch slots.
min_text_length int 500 Extracted-text length below which a page is considered "thin" (fallback candidate).
request_timeout int 30 Per-request timeout in seconds.
selenium_config Optional[dict] None Extra kwargs forwarded to SeleniumSetup (e.g. {"browser": "chrome", "headless": True}).
use_browser_fallback bool True Master switch for the Selenium fallback.

Method ArticleFetcher.fetch_feed_xml

Download a feed's raw XML.

fetch_feed_xml(url: str) -> str

Parameter Type Default Description
url str Feed URL.

Returns: str — The response body.

Raises:

  • RuntimeError — On non-200 responses.
  • aiohttp.ClientError / asyncio.TimeoutError — On transport errors.

Method ArticleFetcher.parse_feed

Parse feed XML with feedparser off the event loop.

parse_feed(xml: str) -> Any

Parameter Type Default Description
xml str Raw feed XML.

Returns: Any — The feedparser.FeedParserDict.

Raises:

  • RuntimeError — When feedparser is not installed.

Method ArticleFetcher.fetch_page

Fetch the complete content of an article page.

fetch_page(url: str, use_browser: bool = False) -> FetchedPage

Parameter Type Default Description
url str Article URL.
use_browser bool False Skip aiohttp and go straight to Selenium.

Returns: FetchedPage — class:FetchedPage; on total failure html is '' and error explains why.

Method ArticleFetcher.close

Quit the shared Selenium driver, ignoring shutdown errors.

close() -> None

Attribute DEFAULT_USER_AGENT

Alias FetchedPage

Re-exported from parrot_tools.rss.models.FetchedPage.

Attribute HAS_FEEDPARSER

Attribute HAS_TRAFILATURA

Function extract_text

Extract the main readable text from an HTML page.

Uses trafilatura when installed; otherwise falls back to a BeautifulSoup text dump with script/style/noscript removed.

extract_text(html: str) -> str

Parameter Type Default Description
html str Raw page HTML.

Returns: str — Extracted text, or '' when nothing could be extracted.

Attribute logger

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