Skip to main content

Python library that provides a simple way to render HTML content in a web browser.

Project description

render_html_v2

render_html_v2 is a fork of the library render_html by bmika1 found here https://github.com/bmika1/render-html it keeps the api the same but gives you the option to include your own encoding. It allows you to open HTML content directly from a string or save it to a file and open it from the file. You can also specify the name of a browser to use a non-default browser. Please refer to webbrowser documentation for the complete list of predefined browsers. This library is especially useful for quickly visualizing and testing HTML content in a web browser environment.

Installation

You can install render_html_v2 using pip:

pip install render-html-v2

NOTE: the library requires Python 3.10 or newer

Usage

from render_html import render_in_browser as ren
import requests

# Making a request with the requests library
response = requests.get('https://example.com')

# Rendering the HTML response in the default browser
html_content = response.text
ren(html_content)

Documentation

render_in_browser(html_string, save_path=None, browser=None, encoding=None)

Render the HTML content in a web browser.

  • html_string (str): The HTML content as a string.
  • save_path (str, optional): The path to save the HTML content as a file. If provided, the HTML content will be saved to the specified file and opened from it. If not provided or set to None, a temporary file will be created in the operating system's default temporary directory. The temporary file will be removed once the rendering is complete.
  • browser (str, optional): The name of the web browser to use (i.e., "chrome", "safari"). If provided, the HTML content will be opened using the specified browser. If not provided or set to None, the default browser will be used.
  • encoding (str, optional) the encoding method you want to encode your content If not provided, the default option will be chosen

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

render_html_v2-1.0.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

render_html_v2-1.0.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file render_html_v2-1.0.0.tar.gz.

File metadata

  • Download URL: render_html_v2-1.0.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for render_html_v2-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f6feb67c79f6b30208ebee4b14c031eae1ceb0327bfcc45f45c1cd2c4b3e5489
MD5 4159d1c02f1662f0ae6a489b42c95e8e
BLAKE2b-256 f67c87516cb48e8cc6d27ffef99f961e00072e7af537e95a0e392cc3b6f1a88f

See more details on using hashes here.

File details

Details for the file render_html_v2-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: render_html_v2-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for render_html_v2-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e060703d590dbad94f6bfa3850bcde0ad8b7ec355a127f0da2deec03f18afd5c
MD5 f6b611c9d826a3b0f8ed304527e28ef4
BLAKE2b-256 6001256d15df0687a74b329ed71d891ab7eff769113afc17ea29bc7298ea63f0

See more details on using hashes here.

Supported by

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