Skip to main content

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

Metadata

Release files for urlrender 0.1.1

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

Source distribution (sdist)

Source distribution for urlrender 0.1.1
File Size Uploaded Provenance Actions
urlrender-0.1.1.tar.gz 6.3 kB Without provenance Details for urlrender-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 12.8 kB

Release files / urlrender-0.1.1.tar.gz

Download URL urlrender-0.1.1.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f6594317e726dbe1f079d36ae9c35c08aea5d806d776eef985b43ae131ea70d6
BLAKE2b-256 checksum
How to use checksums
1f565bd18b4629f8da901d47f4cebe9660f40bb09f71e19228efb51cedd49a49
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.1-py3-none-any.whl

Download URL urlrender-0.1.1-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d82bc8e30ca47303b231e6b9b1dbd66462a5e81103f49d57fef5f137887effbb
BLAKE2b-256 checksum
How to use checksums
a7a219ee0e2e95ecd2fd0f0f9450cd823606f91db33a30fc4e0bf0803d7711d8
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.1

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