Skip to main content

A simple HTML Parser

Project description

Haruka Parser

A simple HTML Parser

Install

pip install haruka-parser

Usage

from haruka_parser.extract import extract_text

html = """<!DOCTYPE html>
<html>
<body>
<!-- Using MathML -->
<p>Using MathJax:</p>
<script type="math/tex; mode=display" id="MathJax-Element-1">{e}^{i\pi }=-1</script>
<!-- Using MathML -->
<p>Using MathML:</p>
<math xmlns="http://www.w3.org/1998/Math/MathML">
  <msup>
    <mi>e</mi>
    <mrow>
      <mi>i</mi>
      <mi>&#x03C0;</mi>
    </mrow>
  </msup>
  <mo>=</mo>
  <mn>-1</mn>
</math>

<!-- Using AsciiMath -->
<p>Using AsciiMath:</p>
<script type="math/asciimath">
e^(i*pi) = -1
</script>

</body>
</html>"""

text, info = extract_text(html)
print(text)
print(info)

Configurations

from haruka_parser.extract import DEFAULT_CONFIG
DEFAULT_CONFIG = {
    "readability": False,
    "skip_large_links": False,
    "extract_latex": True,
    "extract_cnki_latex": False,
    "escape_dollars": True,
    "remove_buttons": True,
    "remove_edit_buttons": True,
    "remove_image_figures": True,
    "markdown_code": True,
    "markdown_headings": True,
    "remove_chinese": False,
    "boilerplate_config": {
        "enable": False,
        "ratio_threshold": 0.18,
        "absolute_threshold": 10,
        "end_threshold": 15,
    },
}

Parsing speed

10k Page:

method haruka-parser 0.5.2 haruku-parser 0.4.9 html2text inscriptis trafilatura
Speed 379.4s 391.6s 272.8s 114.7s 343.9s

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

haruka_parser-1.1.2.tar.gz (37.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

haruka_parser-1.1.2-py3-none-any.whl (37.8 MB view details)

Uploaded Python 3

File details

Details for the file haruka_parser-1.1.2.tar.gz.

File metadata

  • Download URL: haruka_parser-1.1.2.tar.gz
  • Upload date:
  • Size: 37.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for haruka_parser-1.1.2.tar.gz
Algorithm Hash digest
SHA256 f036647e94ebac890a00bb611e47284d509e35c7bf5d3b2930abd677bf5866e9
MD5 0f24490c3c717c2c1b7c52fc9273d6d7
BLAKE2b-256 17358af05d8472cf99e95f4d64448c0aa764b2685b3b38ff4935e6859869caa0

See more details on using hashes here.

File details

Details for the file haruka_parser-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: haruka_parser-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 37.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for haruka_parser-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 85133f49857f1f25e0b0c9a44d046bb401daf5e3428ffb2ee7403c16caa60d44
MD5 d53f109c95617eee628cccf037f4ee8d
BLAKE2b-256 8c17e76e473bfba7eb60646ec072ab1dc94b24953d6a0954725b552f09f8a6ee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page