Welcome to Trafilatura’s documentation!

Python package Python versions Travis build status Code Coverage

Issue tracker:https://github.com/adbar/trafilatura/issues

Demo as GIF image


Trafilatura is Python package and command-line tool which seamlessly downloads, parses, and scrapes web page data: it can extract metadata, main body text and comments while preserving part of the text formatting and page structure. The output can be converted to different formats.

Distinguishing between whole page and essential parts can help to alleviate many quality problems related to web texts as it deals with the noise consisting of recurring elements (headers and footers, ads, links/blogroll).

The extractor has to be precise enough not to miss texts or discard valid documents, robust but also reasonably fast. It is designed to run in production on millions of web documents.


  • Seamless online (including page retrieval) or parallelized offline processing:
    • URLs, HTML files or parsed HTML trees as input
  • Several output formats supported:
    • Plain text (minimal formatting)
    • CSV (with metadata, tab-separated values)
    • JSON (with metadata)
    • XML (for metadata and structure)
    • TEI-XML
  • Robust extraction algorithm, using and readability and jusText as fallback, reasonably efficient with lxml:
    • Focus on main text and/or comments
    • Structural elements preserved: paragraphs, titles, lists, quotes, code, line breaks, in-line text formatting (experimental)
    • Extraction of metadata (title, author, date, site name, categories and tags)
  • URL lists:
    • Generation of link lists from ATOM/RSS feeds
    • Efficient processing of URL queue
    • Blacklists or already processed URLs
  • Optional language detection on the extracted content

Evaluation and alternatives

The extraction focuses on the main content, which is usually the part displayed centrally, without the left or right bars, the header or the footer, but including potential titles and (optionally) comments. This task is also known as web scraping, boilerplate removal, DOM-based content extraction, main content identification, or web page cleaning.

For reproducible results see the evaluation page and the evaluation script.


Chiefly with Python package managers: pip install --upgrade trafilatura.

For more details please read the installation documentation.


With Python or on the command-line.

In a nutshell, with Python:

>>> import trafilatura
>>> downloaded = trafilatura.fetch_url('https://github.blog/2019-03-29-leader-spotlight-erin-spiceland/')
>>> trafilatura.extract(downloaded)
# outputs main content and comments as plain text ...

On the command-line:

$ trafilatura -u "https://github.blog/2019-03-29-leader-spotlight-erin-spiceland/"
# outputs main content and comments as plain text ...

For more information please refer to quickstart, usage documentation and tutorials.

Going further

Trafilatura: Italian word for wire drawing.


  • [-] Language detection on the extracted content
  • [-] Duplicate detection at sentence, paragraph and document level using a least recently used (LRU) cache
  • [-] URL lists and document management
  • [ ] Configuration and extraction parameters
  • [ ] Integration of natural language processing tools


Contributions are welcome!

Feel free to file issues on the dedicated page. Thanks to the contributors who submitted features and bugfixes!


This effort is part of methods to derive information from web documents in order to build text databases for research (chiefly linguistic analysis and natural language processing). A significant challenge resides in the ability to extract and pre-process web texts to meet scientific expectations: Web corpus construction involves numerous design decisions, and this software packages can help facilitate collection and enhance corpus quality.


You can contact me via my contact page or GitHub.

Indices and tables