Convert JSON to BeautifulSoup object
Project description
Jsoup
Jsoup is a python library that helps to parse and build HTML/XML structures using JSON format.
Installation
Use the package manager pip to install jsoup.
pip install jsoup
Usage
from jsoup import JsonTreeBuilder
from bs4 import BeautifulSoup
json = {
"body": {
"h1": {"attrs":{"class":"heading1"}, "text":"Hello World"},
"p": ["this ", "is ", "a ","test 1<2 && 2>1", {"comment":["this is a comment"]}],
"comment": "this is also a comment",
"br": None,
"form" : {
"attrs": {
"method": "post"
},
"input": {"attrs":{
"type": "text",
"name": "username"
}}
}
}
}
soup = BeautifulSoup(json, builder=JsonTreeBuilder)
print(soup.prettify())
Output
<body>
<h1 class="heading1">
Hello World
</h1>
<p>
this
</p>
<p>
is
</p>
<p>
a
</p>
<p>
test 1<2 && 2>1
</p>
<p>
<!--this is a comment-->
</p>
<!--this is also a comment-->
<br/>
<form method="post">
<input name="username" type="text"/>
</form>
</body>
Contributing
We welcome contributions to jsoup
. To get started, follow these steps:
- Fork the repository and clone it to your local machine.
- Create a new branch for your changes.
- Make your changes and write tests to cover them.
- Ensure all tests pass by running
python -m unittest discover -v
. - Push your changes to your fork and create a pull request.
We appreciate all contributions and thank all the contributors!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jsoup-0.0.1.tar.gz
(4.2 kB
view details)
Built Distributions
jsoup-0.0.1-py3.8.egg
(6.8 kB
view details)
jsoup-0.0.1-py3-none-any.whl
(4.8 kB
view details)
File details
Details for the file jsoup-0.0.1.tar.gz
.
File metadata
- Download URL: jsoup-0.0.1.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a0208f03d160d72dbda903c343eeeb7e10535a245b48bbf9c92c84617027ee3 |
|
MD5 | 12f2dbef388b2ad308b990eedb451f92 |
|
BLAKE2b-256 | 065d7e1e8b18128b6c6ebb7633a15f0fed47d71dd2b12b7c0ac4542dec071bb4 |
File details
Details for the file jsoup-0.0.1-py3.8.egg
.
File metadata
- Download URL: jsoup-0.0.1-py3.8.egg
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0d2b77da0ee7a58a0cf3a9c2f2c50efea3d6d64d0baaa28fb26523b82c6ec4d |
|
MD5 | ec7929a1fd8b9d6264726dd7a6a75b9f |
|
BLAKE2b-256 | a891016e5cb414583a44e6f5786b6f0f5d6c93b0e6fb0f51ca3e324c9337954f |
File details
Details for the file jsoup-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: jsoup-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad496a2412da0ec03cc70a1719f1dbb7bbc3665f0499c6ae9ee364a3a3e02139 |
|
MD5 | 6070564c931282c5ec414570af667853 |
|
BLAKE2b-256 | 0cd4b944a8d5ce404272da35c5909f9252a9452befa35b2336be473ac7c28ebb |