Trafilatura turns raw HTML into clean, structured text. It discovers, downloads, and extracts the main content from web pages — stripping boilerplate, navigation, and ads — while preserving metadata like title, author, date, and tags. Use it as a Python library or as a command-line tool, with no database required.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/adbar/trafilatura/llms.txt
Use this file to discover all available pages before exploring further.
Installation
Install via pip and set up optional speed and language-detection extras.
Quickstart
Fetch a URL and extract clean text in three lines of Python.
Python Usage
Full API walkthrough: extraction options, output formats, and metadata.
CLI Usage
Process URLs, files, and directories from the command line.
Web Discovery
Download pages, parse feeds and sitemaps, and run focused crawls.
API Reference
Complete reference for every public function and configuration option.
What Trafilatura Does
Trafilatura handles the full pipeline from URL to clean text:Discover
Find URLs through RSS/Atom feeds, XML sitemaps, or focused web crawling. Filter by language, URL pattern, or domain.
Download
Fetch pages with polite rate-limiting, parallel threads, and automatic fallback to the Internet Archive for unavailable pages.
Extract
Remove boilerplate using a combination of custom heuristics, jusText, and readability algorithms. Tune precision vs. recall to match your use case.
Key Features
Multiple Output Formats
TXT, CSV, JSON, HTML, Markdown, XML, and TEI-XML. Combine with metadata extraction for structured datasets.
Precision & Recall Tuning
Pass
favor_precision=True or favor_recall=True to balance noise reduction against content completeness.Feed & Sitemap Support
Discover URLs from Atom, RSS, and JSON feeds, or crawl XML sitemaps with language filtering.
Focused Web Crawler
Follow internal links with politeness rules, deduplication, and configurable depth limits.
Parallel Downloads
Process lists of URLs concurrently with
--parallel or threaded Python code.Deduplication
Remove duplicate segments and near-duplicate documents using LRU caches and locality-sensitive hashing.