Weblite
A text-based web representation that retains meaningful structure information while displaying only human-visible content.
Version 0.2.0 - Major API improvements!
Overview
Weblite transforms complex web pages into a clean, text-based representation optimized for both LLMs and human comprehension. By extracting only the visible elements and their hierarchical relationships, it creates a simplified yet structurally accurate view of web content.
Key characteristics:
- LLM-Optimized: Designed for AI agents to understand and interact with web pages efficiently
- Human-Readable: Clear, intuitive format that humans can easily parse and understand
- Structural Integrity: Preserves the DOM hierarchy and element relationships, unlike flat accessibility trees
- Selector Construction: Maintains enough structural context to enable accurate CSS/XPath selector generation
- Visibility-Focused: Filters out hidden elements, displaying only what users actually see on the page
This approach bridges the gap between raw HTML complexity and oversimplified text extraction, providing just the right amount of information for effective web automation and analysis.
Documentation
See the docs/ folder for detailed documentation:
- Tree Format - Understanding weblite's output structure
- Pruning Rules - How wrapper elements are collapsed
- Selectors - Smart element targeting (coming soon)
- Agent Integration - Using weblite with AI agents
Installation
Install weblite using pip:
pip install weblite
Or install from source:
git clone https://github.com/steve-z-wang/weblite.git
cd weblite
pip install -e .
Requirements
- Python 3.8 or higher
- Playwright (automatically installed as a dependency)
After installation, you'll need to install Playwright browsers:
playwright install
Quick Start
import asyncio
from playwright.async_api import async_playwright
from weblite import PlaywrightPage
async def scrape_page():
async with async_playwright() as p:
browser = await p.chromium.launch()
page = await browser.new_page()
await page.goto("https://example.com")
# Convert to weblite format
web_page = PlaywrightPage(page)
element = await web_page.to_weblite()
if element:
# Get the simplified representation
result = element.to_dict(collapse_wrappers=True)
print(result)
await browser.close()
asyncio.run(scrape_page())
Output Example
Input HTML:
<div class="wrapper">
<h1>Products</h1>
<div class="card">
<h3>Laptop</h3>
<p>$999</p>
<button>Add to Cart</button>
</div>
</div>
Weblite Output:
{
"main": [
{"h1": "Products"},
{
"div": [
{"h3": "Laptop"},
{"p": "$999"},
{"button": "Add to Cart"}
]
}
]
}
Metadata
Release files for weblite 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| weblite-0.2.3.tar.gz | 13.9 kB | With provenance | Details for weblite-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| weblite-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for weblite-0.2.3-py3-none-any.whl |
Total release size: 33.7 kB
Release files / weblite-0.2.3.tar.gz
| Download URL | weblite-0.2.3.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
14f3888bd1ba51a85e8026805845563f27abce421943d669eda33764fdbc7192
|
|
BLAKE2b-256 checksum How to use checksums |
54673d5fc5a0ed8ca3a35f84da38d21fc812922336280ceef6fec4990d60f332
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 16, 2025.
Transparency logRelease files / weblite-0.2.3-py3-none-any.whl
| Download URL | weblite-0.2.3-py3-none-any.whl |
|---|---|
| Size | 19.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
43b7c5a419f75ac618859f370a817885c17067ac42151dee11678d9eddc7cad9
|
|
BLAKE2b-256 checksum How to use checksums |
f44597dd8c577babf9ba69b3b7e72b370b2ec458bde79b2e852776d72310f4e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 16, 2025.
Transparency logSecurity for weblite 0.2.3
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for weblite-0.2.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 16, 2025.
Transparency logA 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.