diff options
| author | CoprDistGit <infra@openeuler.org> | 2023-05-31 03:39:31 +0000 |
|---|---|---|
| committer | CoprDistGit <infra@openeuler.org> | 2023-05-31 03:39:31 +0000 |
| commit | e45ac55f4de39cf4195ba2594016953ff507043e (patch) | |
| tree | 63a662380fbcc339fc92125870c510b948e3cc06 | |
| parent | 7f3b12860da699ad833cb252a29286e3717dba11 (diff) | |
automatic import of python-html-to-json
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | python-html-to-json.spec | 520 | ||||
| -rw-r--r-- | sources | 1 |
3 files changed, 522 insertions, 0 deletions
@@ -0,0 +1 @@ +/html_to_json-2.0.0.tar.gz diff --git a/python-html-to-json.spec b/python-html-to-json.spec new file mode 100644 index 0000000..27d0725 --- /dev/null +++ b/python-html-to-json.spec @@ -0,0 +1,520 @@ +%global _empty_manifest_terminate_build 0 +Name: python-html-to-json +Version: 2.0.0 +Release: 1 +Summary: Convert html to json. +License: MIT License +URL: https://github.com/fhightower/html-to-json +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/da/83/c425c27e4c8f4b622901f8b58ad48e53be14a080d341a70c67570f1ec30a/html_to_json-2.0.0.tar.gz +BuildArch: noarch + +Requires: python3-bs4 + +%description +# HTML to JSON + +[](https://pypi.python.org/pypi/html-to-json) +[](https://travis-ci.com/fhightower/html-to-json) +[](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'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 + +In addition to converting HTML to JSON, this library can also intelligently convert HTML tables to JSON. + +Currently, this library can handle three types of tables: + +A. Those with [table headers](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th) in the first row +B. Those with table headers in the first column +C. Those without table headers + +Tables of type A and B are diagrammed below: + + + +#### Example + +This code: + +```python +import html_to_json + +html_string = """<table> + <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) +``` + +will produce this 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). + + + + +%package -n python3-html-to-json +Summary: Convert html to json. +Provides: python-html-to-json +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-html-to-json +# HTML to JSON + +[](https://pypi.python.org/pypi/html-to-json) +[](https://travis-ci.com/fhightower/html-to-json) +[](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'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 + +In addition to converting HTML to JSON, this library can also intelligently convert HTML tables to JSON. + +Currently, this library can handle three types of tables: + +A. Those with [table headers](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th) in the first row +B. Those with table headers in the first column +C. Those without table headers + +Tables of type A and B are diagrammed below: + + + +#### Example + +This code: + +```python +import html_to_json + +html_string = """<table> + <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) +``` + +will produce this 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). + + + + +%package help +Summary: Development documents and examples for html-to-json +Provides: python3-html-to-json-doc +%description help +# HTML to JSON + +[](https://pypi.python.org/pypi/html-to-json) +[](https://travis-ci.com/fhightower/html-to-json) +[](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'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 + +In addition to converting HTML to JSON, this library can also intelligently convert HTML tables to JSON. + +Currently, this library can handle three types of tables: + +A. Those with [table headers](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th) in the first row +B. Those with table headers in the first column +C. Those without table headers + +Tables of type A and B are diagrammed below: + + + +#### Example + +This code: + +```python +import html_to_json + +html_string = """<table> + <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) +``` + +will produce this 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). + + + + +%prep +%autosetup -n html-to-json-2.0.0 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-html-to-json -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Wed May 31 2023 Python_Bot <Python_Bot@openeuler.org> - 2.0.0-1 +- Package Spec generated @@ -0,0 +1 @@ +3435ba0c28a24aa9d273cc05799c91a7 html_to_json-2.0.0.tar.gz |
