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.8.0.tar.gz
(36.6 MB
view details)
Built Distribution
File details
Details for the file haruka_parser-0.8.0.tar.gz
.
File metadata
- Download URL: haruka_parser-0.8.0.tar.gz
- Upload date:
- Size: 36.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b774a297333e7d1e0ddcc0b682f35fa7fd6c5c4566c077369e0e38ebc3ca0adb |
|
MD5 | 1cd4c3c73d6fea4ef2c40e3b3247c719 |
|
BLAKE2b-256 | 77efd0a66fb1074adcc19ae2370c5059da465fec4f7f2f71803294885a95a545 |
File details
Details for the file haruka_parser-0.8.0-py3-none-any.whl
.
File metadata
- Download URL: haruka_parser-0.8.0-py3-none-any.whl
- Upload date:
- Size: 36.8 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36390302774bcbf72035f5a021f7d88a155ac7ff4ff8d45024425292641b361f |
|
MD5 | c7b89f5f297daa9517fc03f9628b1b9d |
|
BLAKE2b-256 | 9b1a897bb648bc826163e240a19bac36c52c6a13ad2eca25cfaa7c7160585c32 |