Convert bs4 Tags into Json
Project description
Convert HTML Tags of BeautifulSoup class to JSON data.
Installation
This package is available on PyPi. Just use pip install -U bs2json
to install it. Then you can import it using from bs2json import bs2json
.
Example Syntax
from bs2json import BS2Json
html = '<html><head><title>Page Title</title></head><body><h1>My First Heading</h1><p>My first paragraph.</p></body></html>'
bs2json = BS2Json(html)
# Convert soup to JSON
json_obj = bs2json.convert()
# Save JSON to file
bs2json.save()
# Print prettified output
bs2json.prettify()
Plus point
You can also use the module methods as an extension to the element.Tag
.
For more information, see the example_ext.py
file from examples
What's new
- Ability to initialize the bs4 object from given string
- Converts a single bs4 tag or a tag matching the given string to a JSON object
- Option to include or exclude comments in the JSON representation
- Option to remove whitespaces from the start and end of text
- Ability to save the converted object to a file
- Ability to prettify the output of the last converted object
- Option to set custom labels for converting BeautifulSoup elements to JSON
Contributing
We appreciate all contributions. If you are planning to contribute any bug-fixes, please do so without further discussions.
If you plan to contribute new features etc. please first open an issue or reuse an exisiting issue, and discuss the feature with us. We will discuss with you on the issue timely or set up conference calls if needed.
We appreciate all contributions and thank all the contributors!
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
Built Distributions
File details
Details for the file bs2json-0.1.2.tar.gz
.
File metadata
- Download URL: bs2json-0.1.2.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b881c295c48b354ea80a68c1e0f5a7f0038a3c31b6dd1a55cd8205ecba01dee9 |
|
MD5 | bfba480d7374f9f92d139b1980766bd0 |
|
BLAKE2b-256 | 4b541327c91854351fdde23bd0a61444e1439b69d01d1ff68bbd0306e5f70ed1 |
File details
Details for the file bs2json-0.1.2-py3.8.egg
.
File metadata
- Download URL: bs2json-0.1.2-py3.8.egg
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfb2b3710ce2e00c41db9d0c5487b8dfb0ca2943d31632576bde89832ad4fa56 |
|
MD5 | 80c95b0d685b10b80933812dee2d6f0a |
|
BLAKE2b-256 | 2dd8724addf7aa4b0da544d1f46038135de5cd01dc9b6f66226624167f00f1a7 |
File details
Details for the file bs2json-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: bs2json-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.6 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 | b24eb8147ddcaf883273d6068d32a44c0f5a77d8c11358b8b983308b9d8ad292 |
|
MD5 | a91511d0b8187c838330a0a01d711c81 |
|
BLAKE2b-256 | bd2d2a2f77ac22c345b4d13ebddbcaeb62040ff92cbc1dd31cb3ae402090eff4 |