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>π</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
Release history Release notifications | RSS feed
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.5.tar.gz
(6.8 MB
view details)
Built Distribution
File details
Details for the file haruka_parser-0.6.5.tar.gz
.
File metadata
- Download URL: haruka_parser-0.6.5.tar.gz
- Upload date:
- Size: 6.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 551d0d0b1d27e2c6cd96ef4ffc30423f66bee9dadfd1f695feb37e2e444a77dc |
|
MD5 | 134988c0ad8f007db4a05f1939e2c3d6 |
|
BLAKE2b-256 | 59d92a685c4840730d17fab1be92b90ad6a23a1f91f222439e463ba0318ca931 |
File details
Details for the file haruka_parser-0.6.5-py3-none-any.whl
.
File metadata
- Download URL: haruka_parser-0.6.5-py3-none-any.whl
- Upload date:
- Size: 6.9 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39b8711b999f00c95ed756d3c929beb2599326de36ec9ae3895a5e4fe11c0eac |
|
MD5 | 02b6cf34b3b24723951d0a6204d28c46 |
|
BLAKE2b-256 | 534dbdc408d48f7e28598df12ba10c051a51583027c9c9c18621b8e5b67803b3 |