Tools to handle the CRUD of .html files as objects.
Project description
HTML 2 Object
Tools to handle the CRUD of .html files as objects.
Install
pip install html2object
Usage
This project provides a way to manipulate HTML files and update them dynamically. Here's how you can use it:
First, import the necessary classes from this project:
from html2object import HtmlElement
read your html file and create an HtmlElement()
html = open(<path>, "r").read("bin/gui/index.html")
document = HtmlElement(html)
now you can create scripts
update_script = HtmlElement(name="script").add_child(
"setInterval(() => reload(), 1500);"
)
document.add_child(update_script)
create a div
p = HtmlElement(name="p", id="textID").add_chil("Text")
div = HtmlElement(name="div").add_child(p)
document.add_child(div)
or even find an element
text_element = document.find_element_by_id("textID")
strong = HtmlElement(name="strong").add_child("Strong text")
text_element.set_child([strong, "No strong text"])
save the html file running
open(path, "w").write(str(document)).close()
Local setup
Instructions on how to install and set up your project. Include any dependencies that need to be installed.
- Clone the repository
- Navigate to the project directory:
cd html2object
- Create a virtual environment (optional but recommended):
python3 -m venv venv
- Activate the virtual environment:
- For Windows:
venv\Scripts\activate
- For macOS and Linux:
source venv/bin/activate
- Install the project dependencies:
pip install -r requirements.txt
That's it! Your project should now be installed and ready to use.
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
html2object-0.1.4.tar.gz
(5.7 kB
view hashes)
Built Distribution
Close
Hashes for html2object-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72500bda2bba0321dfdfa58ae6d3a76a78e792829425d38e5882771daeed7e12 |
|
MD5 | a53328c2113b4f5a278c9433dff90589 |
|
BLAKE2b-256 | 90618807d64952529981fc46f9a5ad4e3a0d3719f7df4f564c48f9d2fe4b6f1e |