buriy

python-readability: Extract Main Text from HTML Pages

python-readability extracts an article’s main text and title from an HTML document, reducing navigation and other page clutter. It is a Python library for applications that need readable page content, with a command-line option for local files and URLs.

View on GitHub Compare
Stars
2.9k
Forks
352
Stars, last 30 days
-5

Our take

Health score

42/100

How it is scored
Activity
46
Community
61
Issues
40
Pull requests
20

-5 stars in the last 30 days

  • Slower to close issues than 100% of the projects we track

Project history

Daily GitHub snapshots since Oct 7, 2026. History covers stars and forks; health signals are not tracked historically.

Selected snapshot

Stars

2,891

Forks

354

Change since Nov 13, 2026: 0 stars·+1 forks

Overview

python-readability is a Python library that identifies and extracts the main body text and title from an HTML document. It is useful when an application needs article content without the surrounding page clutter, such as navigation and unrelated sections.

The project is suited to developers building content-processing workflows. Its output is cleaned-up HTML, not a guarantee that content is safe to render: untrusted output needs a separate HTML sanitizer.

Key Features

  • Extracts a document's title and main body content.
  • Returns article content as HTML through Document.summary().
  • Supports input as HTML content and provides encoding detection for bytes input.
  • Includes a command-line interface for processing a local HTML file or URL.
  • Offers options and APIs for article metadata and image handling, including authors and keeping multiple images.
  • Includes reproducible page-extraction fixtures and benchmark tooling.

Use Cases

  • A developer can extract article text before indexing pages for search.
  • A content-processing application can present a less cluttered reading view from saved or fetched HTML.
  • A researcher can prepare web articles for downstream text analysis, while retaining HTML structure such as headings and links.
  • A developer can compare extraction changes against the project's real-page fixtures when maintaining a scraping or publishing pipeline.

Getting Started

Install the package with pip:

pip install readability-lxml

See the README for usage examples and further installation options.

Alternatives

  • trafilatura: Trafilatura extracts readable text and metadata for crawlers and research pipelines, while python-readability focuses on an article’s main text and title.
  • newspaper: Newspaper3k targets news sites and also extracts images, keywords, and summaries, while python-readability focuses on article text and title.
ProjectLanguageLicenseStarsStatus
python-readabilityHTMLApache-2.02.9kNot checked yet
trafilaturaPythonApache-2.06.9kActive
newspaperPythonMIT15.2kMaintained

Considerations

  • Extraction is heuristic: page structure and markup can affect which content is selected.
  • Document.summary() is not a general-purpose HTML sanitizer or a security boundary. Sanitize untrusted output with a dedicated allowlist sanitizer and use an appropriate Content Security Policy before rendering it.
  • The package is licensed under Apache-2.0.

Found this useful?

Share it with someone who would like python-readability.

Comparisons