Metadata-Version: 2.1
Name: html-to-json
Version: 1.0.8
Summary: Convert html to json.
Home-page: https://github.com/fhightower/html-to-json
Author: Floyd Hightower
Author-email: 
License: MIT License
Project-URL: Documentation, https://github.com/fhightower/html-to-json
Project-URL: Say Thanks!, https://saythanks.io/to/floyd.hightower27%40gmail.com
Project-URL: Source, https://github.com/fhightower/html-to-json
Project-URL: Tracker, https://github.com/fhightower/html-to-json/issues
Project-URL: PyPi, https://pypi.org/project/html-to-json/
Project-URL: CI, https://travis-ci.com/fhightower/html-to-json.svg?branch=main
Description: # HTML to JSON
        
        [![PyPI](https://img.shields.io/pypi/v/html-to-json.svg)](https://pypi.python.org/pypi/html-to-json)
        [![Build Status](https://travis-ci.com/fhightower/html-to-json.svg?branch=main)](https://travis-ci.com/fhightower/html-to-json)
        [![codecov](https://codecov.io/gh/fhightower/html-to-json/branch/main/graph/badge.svg?token=V0WOIXRGMM)](https://codecov.io/gh/fhightower/html-to-json)
        
        Convert HTML and/or HTML tables to JSON.
        
        ## Installation
        
        ```
        pip install html-to-json
        ```
        
        ## Usage
        
        ### HTML to JSON
        
        ```python
        import html_to_json
        
        html_string = """<head>
            <title>Test site</title>
            <meta charset="UTF-8"></head>"""
        output_json = html_to_json.convert(html_string)
        print(output_json)
        ```
        
        When calling the `html_to_json.convert` function, you can choose to not capture the text values from the html by passing in the key-word argument `capture_element_values=False`. You can also choose to not capture the attributes of the elements by passing `capture_element_attributes=False` into the function.
        
        #### Example
        
        Example input:
        
        ```html
        <head>
            <title>Floyd Hightower's Projects</title>
            <meta charset="UTF-8">
            <meta name="description" content="Floyd Hightower&#39;s Projects">
            <meta name="keywords" content="projects,fhightower,Floyd,Hightower">
        </head>
        ```
        
        Example output:
        
        ```json
        {
            "head": [
            {
                "title": [
                {
                    "_value": "Floyd Hightower\'s Projects"
                }],
                "meta": [
                {
                    "_attributes":
                    {
                        "charset": "UTF-8"
                    }
                },
                {
                    "_attributes":
                    {
                        "name": "description",
                        "content": "Floyd Hightower\'s Projects"
                    }
                },
                {
                    "_attributes":
                    {
                        "name": "keywords",
                        "content": "projects,fhightower,Floyd,Hightower"
                    }
                }]
            }]
        }
        ```
        
        ### HTML Tables to JSON
        
        ```python
        import html_to_json
        
        html_string = """<table class="table table-striped table-bordered table-hover">
            <tr>
                <th>#</th>
                <th>Malware</th>
                <th>MD5</th>
                <th>Date Added</th>
            </tr>
            
            <tr>
                <td>25548</td>
                <td><a href="/stats/DarkComet/">DarkComet</a></td>
                <td><a href="/config/034a37b2a2307f876adc9538986d7b86">034a37b2a2307f876adc9538986d7b86</a></td>
                <td>July 9, 2018, 6:25 a.m.</td>
            </tr>
            
            <tr>
                <td>25547</td>
                <td><a href="/stats/DarkComet/">DarkComet</a></td>
                <td><a href="/config/706eeefbac3de4d58b27d964173999c3">706eeefbac3de4d58b27d964173999c3</a></td>
                <td>July 7, 2018, 6:25 a.m.</td>
            </tr></table>"""
        tables = html_to_json.convert_tables(html_string)
        print(tables)
        ```
        
        Currently, this package can handle tables with the headers in the first row or tables with headers in the first column as depicted below:
        
        ![This package can handle tables with the headers in the first row or headers in the first column](./html_table_varieties.jpg)
        
        #### Example
        
        Example input:
        
        ```html
        <table class="table table-striped table-bordered table-hover">
            <tr>
                <th>#</th>
                <th>Malware</th>
                <th>MD5</th>
                <th>Date Added</th>
            </tr>
            
            <tr>
                <td>25548</td>
                <td><a href="/stats/DarkComet/">DarkComet</a></td>
                <td><a href="/config/034a37b2a2307f876adc9538986d7b86">034a37b2a2307f876adc9538986d7b86</a></td>
                <td>July 9, 2018, 6:25 a.m.</td>
            </tr>
            
            <tr>
                <td>25547</td>
                <td><a href="/stats/DarkComet/">DarkComet</a></td>
                <td><a href="/config/706eeefbac3de4d58b27d964173999c3">706eeefbac3de4d58b27d964173999c3</a></td>
                <td>July 7, 2018, 6:25 a.m.</td>
            </tr>
        </table>
        ```
        
        Example output:
        
        ```json
        [
            [
                {
                    '#': '25548',
                    'Malware': 'DarkComet',
                    'MD5': '034a37b2a2307f876adc9538986d7b86',
                    'Date Added': 'July 9, 2018, 6:25 a.m.'
                }, {
                    '#': '25547',
                    'Malware': 'DarkComet',
                    'MD5': '706eeefbac3de4d58b27d964173999c3',
                    'Date Added': 'July 7, 2018, 6:25 a.m.'
                }
            ]
        ]
        ```
        
        ## Credits
        
        This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and fhightower's [Python project template](https://github.com/fhightower-templates/python-project-template).
        
Keywords: html to json,html,json,conversion
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Description-Content-Type: text/markdown
