Skip to main content

webpage2content

A simple Python package that takes a web page (by URL) and extracts its main human-readable content. It uses LLM technology to remove all of the boilerplate webpage cruft (headers, footers, copyright and accessibility notices, advertisements, login and search controls, etc.) that isn't part of the main content of the page.

Installation

pip install webpage2content

Usage

Python

import openai
from webpage2content import webpage2content

text = webpage2content("http://mysite.com", openai.OpenAI(api_key="your_openai_api_key"))
print(text)

CLI

You can invoke webpage2content from the command line.

webpage2content https://slashdot.org/

If you don't have your OPENAI_API_KEY environment variable set, you can pass it to the CLI invocation as a second argument.

webpage2content https://slashdot.org/ sk-ABCD1234

You can also specify the OpenAI organization ID if needed.

webpage2content https://slashdot.org/ sk-ABCD1234 org-5678

Additional CLI Options

  • Logging Level: You can set the logging level using the -l or --log-level option.

    webpage2content -l DEBUG https://slashdot.org/
    
  • Version: Display the version number of the package.

    webpage2content -v
    
  • Help: Display help information.

    webpage2content -h
    

Environment Variables

  • OPENAI_API_KEY: Your OpenAI API key.
  • OPENAI_ORGANIZATION_ID: Your OpenAI organization ID (optional).

.env File Support

The CLI will honor .env files for setting environment variables. Create a .env file in the same directory with the following content:

OPENAI_API_KEY=your_openai_api_key
OPENAI_ORGANIZATION_ID=your_openai_organization_id

Example

webpage2content -l INFO https://example.com/ sk-ABCD1234 org-5678

This command will extract the main content from https://example.com/ using the provided OpenAI API key and organization ID, with logging set to INFO level.


Metadata

Release files for webpage2content 1.3.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for webpage2content 1.3.4
File Size Uploaded Provenance Actions
webpage2content-1.3.4.tar.gz 16.9 kB Without provenance Details for webpage2content-1.3.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for webpage2content 1.3.4
File Interpreter ABI Platform Actions
webpage2content-1.3.4-py3-none-any.whl Python 3 none any Details for webpage2content-1.3.4-py3-none-any.whl

Total release size: 33.5 kB

Release files / webpage2content-1.3.4.tar.gz

Download URL webpage2content-1.3.4.tar.gz
Size 16.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d962dcec71cbcd05cebbd82566bddd6d9a12346bf0fa6b78e8a566320cfc9d05
BLAKE2b-256 checksum
How to use checksums
32f61b92f5244e82ccaca7a696b32ab55df0e2e2577f39c55e74d998fe677313
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Release files / webpage2content-1.3.4-py3-none-any.whl

Download URL webpage2content-1.3.4-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc4df43ea8e43758f37a3203b090272f71461879c11782806050df01fa22647a
BLAKE2b-256 checksum
How to use checksums
6362d723bf5eeaa97b96252952c34b491c5b4b9e17ee9e8b58edd5ccff721830
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Security for webpage2content 1.3.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page