The `html-to-json` Python library, currently at version 2.0.0, provides functionality to convert HTML strings into a JSON representation. It also includes intelligent conversion for HTML tables. The project is currently in maintenance mode, with the author seeking sponsorship for active development and ongoing upkeep.
pip install html-to-jsonVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to convert a basic HTML string into JSON using the `html_to_json.convert` function. It also shows how to use the `capture_element_values` and `capture_element_attributes` parameters to control the output format.
Consider contributing to the project or sponsoring the author for continued development.
Review your `html_to_json.convert()` calls and explicitly set `capture_element_values` or `capture_element_attributes` if precise control over the JSON output's value or attribute inclusion is required.
Refer to the official GitHub README for `fhightower/html-to-json` version 2.0.0 for the correct function signature and available keyword arguments (e.g., `capture_element_values`, `capture_element_attributes`).
Understand that the library's JSON output for elements typically includes nested dictionaries with keys like `_value` for text and `_attributes` for HTML attributes. Adjust your JSON parsing logic accordingly. For example, `output_json['head'][0]['title'][0]['_value']` to access the title text.
Ensure the input HTML is well-formed. Use a HTML validator if the source HTML is external or untrusted. Inspect the raw output of `html_to_json.convert()` before attempting `json.loads()` to identify any intermediate parsing issues.
No dependency data recorded yet.