Trafilatura: Advanced Web Scraping and Text Extraction in Python

This repository profile is provided by osrepos.com, an open source repository discovery platform.

Trafilatura: Advanced Web Scraping and Text Extraction in Python

Summary

Trafilatura is a robust Python package and command-line tool designed for gathering text and metadata from the web. It simplifies web crawling, scraping, and content extraction, transforming raw HTML into structured data. Widely adopted by major companies and institutions, it offers high efficiency and accuracy for various text processing needs.

Repository Information

Analyzed by OSRepos on May 1, 2026

Topics

Click on any tag to explore related repositories

Use at your own risk

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.

Introduction

Trafilatura is a cutting-edge Python package and command-line tool designed to gather text and metadata from the Web. It simplifies the process of turning raw HTML into structured, meaningful data, offering essential components for web crawling, downloads, scraping, and extraction of main texts, metadata, and comments. Recognized for its robustness and speed, Trafilatura is widely used by companies like HuggingFace, IBM, and Microsoft Research, as well as by renowned academic institutions.

Installation

Installing Trafilatura is straightforward and can be done using pip:

pip install trafilatura

Examples

Here's how you can use Trafilatura to extract text from a URL or an HTML string:

import trafilatura
from trafilatura.downloads import fetch_url

# Example 1: Extract from a URL
url = "https://adrien.barbaresi.eu/blog/trafilatura-web-scraping.html"
print(f"Extracting from: {url}")
downloaded = fetch_url(url)
if downloaded:
    text = trafilatura.extract(downloaded)
    print("--- Extracted Content (first 500 characters) ---")
    print(text[:500])
    print("----------------------------------------------------")

# Example 2: Extract from an HTML string
html_content = """

    My Test Page
    
        

Main Title

This is an example paragraph with <b>bold text</b>.

  • Item 1
  • Item 2
""" print("\nExtracting from an HTML string:") text_from_html = trafilatura.extract(html_content) print("--- Extracted Content ---") print(text_from_html) print("-------------------------")

Why Use Trafilatura?

Trafilatura stands out for several reasons, making it an excellent choice for your web content extraction needs:

  • Efficiency and Accuracy: It consistently outperforms other open-source libraries in text extraction benchmarks, balancing noise limitation with the inclusion of all valid parts.
  • Comprehensive Features: It offers advanced web crawling (sitemaps and feeds support), parallel processing, and robust extraction of main text, metadata (title, author, date), and formatting (paragraphs, titles, lists).
  • Multiple Output Formats: It supports TXT, Markdown, CSV, JSON, HTML, XML, and TEI, providing flexibility for various applications.
  • Modularity and Ease of Use: No database is required, and it's designed to be handy and modular, facilitating integration into your projects.
  • Active Maintenance and Community Support: It receives regular updates, feature additions, and optimizations, backed by comprehensive documentation and an active community.
  • Focus on Content Quality: It helps focus on the actual content, avoiding noise from recurring elements like headers and footers, and making sense of data and metadata.

Links

Related repositories

Similar repositories that may be relevant next.

Benchmark Radar: A Living Database for AI Benchmarks and Evaluation

Benchmark Radar: A Living Database for AI Benchmarks and Evaluation

September 29, 2026

Benchmark Radar is an extensive open-source project that tracks over 20,710 AI benchmark, evaluation, dataset, and data-quality records from 37 public sources. It provides daily updates, linked evidence, and tools for researchers and developers to discover and analyze AI benchmarks. This project is essential for anyone needing to stay current with AI evaluation trends and model performance.

AI BenchmarkLLM EvaluationAgentic Benchmarking
Pydantic AI Harness: Enhancing Your AI Agents with Robust Capabilities

Pydantic AI Harness: Enhancing Your AI Agents with Robust Capabilities

September 28, 2026

Pydantic AI Harness is the official capability and harness library for Pydantic AI, designed to extend agents for complex, long-running tasks. It provides a modular system of "capabilities" for functionalities like file system interaction, web research, memory, and sub-agent delegation. This library enables developers to build sophisticated and durable AI agents with ease.

PythonAIAgents
Bernstein: Open-Source Governance and Orchestration for AI Agents

Bernstein: Open-Source Governance and Orchestration for AI Agents

September 28, 2026

Bernstein is an open-source framework designed for the governance and orchestration of AI agents, allowing users to define rules declaratively. It enforces these policies and generates verifiable, replayable records of all agent activities. This Python-based solution provides a robust layer for managing complex AI agent workflows with transparency and accountability.

AI AgentsAgent GovernanceAI Orchestration
Meshtastic-MCP: AI Tooling for Meshtastic Device Control and Testing

Meshtastic-MCP: AI Tooling for Meshtastic Device Control and Testing

September 27, 2026

Meshtastic-MCP provides an MCP server and agent skills designed for AI tooling to discover, drive, observe, and test Meshtastic devices and applications. It offers a comprehensive suite of capabilities, from portable device control to advanced hardware-free end-to-end testing and replay functionalities. This project aims to streamline the development and testing of Meshtastic ecosystems.

PythonMeshtasticAI

Source repository

Open the original repository on GitHub.

19 counted GitHub visits

View on GitHub
OS
OSRepos

Analysis and discovery of open source repositories. Find interesting projects and follow their updates.

Monitor your website with YourWebsiteScore

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of third-party repository code is at your own risk. Always review source code, dependencies, licenses, and security implications before running anything.

© 2025 OSRepos. Built with Nuxt 3 and lots of ❤️