Skip to main content

A Python package to extract the main content from HTML documents

Project description

HTML Content Extractor

This Python package provides a function to extract the "main content" from HTML documents.

Relevancy is determined by an algorithm that favors the deepest parent with the most h1, h2, h3 and p tags.

Installation

You can install this package via pip:

$ pip install html-content-extractor

Usage

from html_content_extractor import extract_content

>>> html = "<div><h1>An HTML Page</h1><p>This is some HTML content.</p></div>"
>>> content = extract_content(html, format='plaintext')
>>> print(content)
"An HTML Page\n\nThis is some HTML content."

>>> markdown = extract_content(html, format='markdown')
>>> print(content)
"# An HTML Page\n\nThis is some HTML content."

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

html_content_extractor-0.0.3.tar.gz (8.4 kB view hashes)

Uploaded Source

Built Distribution

html_content_extractor-0.0.3-py3-none-any.whl (12.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page