What is Trafilatura?
Trafilatura is a Python package and command-line tool for gathering text on the web and turning raw HTML into structured data. It handles the full path from discovery to output: crawling, downloading, scraping, and extracting the main text, metadata, and comments from a page. It sits in the Web Scraping & Crawling category of the Data & Labeling tools and is open-source, written in Python and licensed Apache-2.0.
Overview
Trafilatura is a Python package and command-line tool for gathering text on the web and turning raw HTML into structured data. It handles the full path from discovery to output: crawling, downloading, scraping, and extracting the main text, metadata, and comments from a page.
It is built for developers and researchers who need clean article content without the surrounding noise. By focusing on the actual content and dropping recurring elements like headers and footers, it produces text that is easier to feed into search indexes, datasets, or NLP pipelines. No database is required, and the output converts to common formats.
Within web scraping and crawling tools, Trafilatura sits at the extraction layer. It supports sitemaps and feeds for finding URLs, processes both live and previously downloaded HTML, and can emit TXT, Markdown, CSV, JSON, HTML, XML, and XML-TEI.
What it does
- Extracts main text plus metadata such as title, author, date, site name, categories, and tags
- Discovers content through sitemaps (TXT, XML) and feeds (ATOM, JSON, RSS) with URL filtering and deduplication
- Processes both live URLs and previously downloaded HTML files or parsed trees, with parallel download queues
- Preserves structure: paragraphs, titles, lists, quotes, code, line breaks, and inline formatting, plus optional comments, links, images, and tables
- Outputs TXT, Markdown, CSV, JSON, HTML, XML, and XML-TEI
- Optional add-ons for language detection on extracted content and speed optimizations
Getting started
Install the package, then extract main text from a URL using either the command line or the Python API.
Install Trafilatura
Install the package from PyPI with pip.
pip install trafilaturaExtract from the command line
Pass a single URL with the -u flag to print its main text.
trafilatura -u "https://github.blog/2019-03-29-leader-spotlight-erin-spiceland/"Extract with Python
Use fetch_url to download a page and extract to get its main text.
from trafilatura import fetch_url, extract
downloaded = fetch_url('https://github.blog/2019-03-29-leader-spotlight-erin-spiceland/')
result = extract(downloaded)
print(result)Commands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Building text datasets from many web pages for research or NLP and LLM training
- Cleaning article content for search indexing or a reading or archiving pipeline
- Crawling a site through its sitemap or feed and exporting articles to JSON, CSV, or Markdown
- Pulling page metadata like author, date, and title alongside the body text
How Trafilatura compares
Trafilatura alongside other open-source web scraping & crawling tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| Firecrawl | ★ 214k | A crawling service and API that converts whole websites into clean Markdown or structured JSON ready for LLMs. |
| Agent Reach | ★ 116k | A capability layer that installs, health-checks and routes readers so a CLI agent can read and search web pages, YouTube, RSS, GitHub, Reddit, Twitter/X and more without API fees. |
| Scrapling | ★ 107k | A Python web scraping framework whose parser relocates your elements when pages change, with stealthy fetchers and a Scrapy-like spider engine for full crawls. |
| Crawl4AI | ★ 88.2k | A local-first Python web crawler that turns pages into clean Markdown for use in RAG and LLM pipelines. |
| Scrapy | ★ 65.7k | A mature Python framework for writing fast spiders that crawl websites and extract structured data at scale. |
| changedetection.io | ★ 36.1k | A self-hosted web page change monitor with XPath/CSS/jq filters, browser steps and restock alerts, which can route every diff through an LLM to suppress noise. |
| ScrapeGraphAI | ★ 33k | A Python library that uses LLMs and a graph pipeline to extract data from pages based on natural-language prompts. |
| Trafilatura | ★ 7.3k | Crawl the web and pull clean main text and metadata out of messy HTML |

