urlrender
A lightweight Python library for rendering JavaScript-enabled web pages using Playwright and Chromium.
Features
- Render JavaScript-enabled web pages.
- Extract rendered HTML and visible text.
- Retrieve page title, final URL, HTTP status code, and rendering time.
- Optionally wait for a CSS selector before extracting content.
- Reuse a browser instance across multiple URLs.
- Simple synchronous API with automatic resource cleanup.
Installation
Install the package:
pip install urlrender
Install Chromium:
python -m playwright install chromium
Requires Python 3.10+.
Quick Start
from urlrender import Renderer
with Renderer() as renderer:
result = renderer.render("https://example.com")
print("Title:", result.title)
print("Status:", result.status_code)
print("URL:", result.url)
print("HTML:", result.html)
print("Text:", result.text)
print("Elapsed:", result.elapsed_ms, "ms")
The context manager automatically closes the browser when finished.
Get HTML or Text
If you only need one output, use the convenience methods:
from urlrender import Renderer
with Renderer() as renderer:
html = renderer.get_html("https://example.com")
text = renderer.get_text("https://example.com")
Each method performs a rendering operation. Use render() when you need multiple fields from the same page.
Wait for an Element
Some websites load content dynamically. Use wait_for_selector to wait for a CSS selector before extracting the page.
from urlrender import Renderer
url = "https://www.imdb.com/title/tt43595281/"
with Renderer(timeout=20000) as renderer:
result = renderer.render(
url,
wait_for_selector='script[type="application/ld+json"]',
)
print(result.html)
The selector wait checks that the element is attached to the DOM; it does not need to be visible.
Configuration
from urlrender import Renderer
with Renderer(
timeout=15000, # Milliseconds
wait_until="domcontentloaded", # Navigation event
headless=True, # Run without a visible window
) as renderer:
result = renderer.render("https://example.com")
Supported wait_until values:
"commit""domcontentloaded"(default)"load""networkidle"
Use headless=False to open a visible Chromium window for debugging.
RenderResult
renderer.render() returns a RenderResult object:
| Attribute | Description |
|---|---|
url |
Final page URL |
html |
Rendered HTML |
text |
Visible text from the page body |
status_code |
Main navigation HTTP status code, or None |
title |
Page title |
elapsed_ms |
Rendering time in milliseconds |
Error Handling
from urlrender import Renderer, NavigationError, RenderTimeoutError
try:
with Renderer(timeout=10000) as renderer:
result = renderer.render(
"https://example.com",
wait_for_selector="main",
)
except RenderTimeoutError as exc:
print("Rendering timed out:", exc)
except NavigationError as exc:
print("Navigation failed:", exc)
Invalid URLs and invalid configuration values can raise ValueError.
Requirements and Limitations
- Chromium must be installed separately using Playwright.
- Some websites may return CAPTCHA, bot-protection, or access-denied pages.
- Dynamically loaded content may require an appropriate selector wait.
- The library does not automatically click elements, scroll pages, or paginate results.
- Browser rendering consumes more resources than ordinary HTTP requests.
Use the library responsibly and follow the target website's terms and access restrictions.
License
MIT License. See LICENSE.
Author
Hemant Malik
- GitHub: @itsmehemant7
Metadata
Release files for urlrender 0.1.2
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 |
|---|---|---|---|---|
| urlrender-0.1.2.tar.gz | 6.3 kB | Without provenance | Details for urlrender-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| urlrender-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for urlrender-0.1.2-py3-none-any.whl |
Total release size: 12.8 kB
Release files / urlrender-0.1.2.tar.gz
| Download URL | urlrender-0.1.2.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
883a89a68fc18423fd315b3288e011874b05174cc227584ff8743cd2b035abbe
|
|
BLAKE2b-256 checksum How to use checksums |
db4e354739fd185887143373de53fef8c3715cd8cad78ba5229d1ae0624b598d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.9
|
Release files / urlrender-0.1.2-py3-none-any.whl
| Download URL | urlrender-0.1.2-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
be0edb2079ddb995a23ff142bf6d13ed2b6f8f40c6d25132073624717f1270f2
|
|
BLAKE2b-256 checksum How to use checksums |
474512b293ab81d7527489686d044fb25a39345f711f4b3eba285a52f12e7786
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.9
|
Security for urlrender 0.1.2
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.