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-0.6.4.tar.gz (6.8 MB view details)

Uploaded Source

Built Distribution

haruka_parser-0.6.4-py3-none-any.whl (6.9 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: haruka_parser-0.6.4.tar.gz
  • Upload date:
  • Size: 6.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.4

File hashes

Hashes for haruka_parser-0.6.4.tar.gz
Algorithm Hash digest
SHA256 143888250bd29ee434ed9bd9ba1a7bb18f6fc33abf4f03f2900dc80040de9a37
MD5 95d5138bb913ad4d63a1ef718619f4f3
BLAKE2b-256 4f6490f39a65d9d7f7c47eee9b465dfe5b396a1d4253f1284e9bb2a67027a08b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for haruka_parser-0.6.4-py3-none-any.whl
Algorithm Hash digest
SHA256 57bef73c7769ae4952669d9e7aa3b2a9a2c02681fc409c544d94fc3eadd68bdd
MD5 9e5929c94f18a8bd2401b926ccdd81f8
BLAKE2b-256 33cbfc47c3c003d596921b8360db24513eed032ee8a6c99417d0baac05625b09

See more details on using hashes here.

Supported by

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