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.7.2.tar.gz
(37.5 MB
view details)
Built Distribution
File details
Details for the file haruka_parser-0.7.2.tar.gz
.
File metadata
- Download URL: haruka_parser-0.7.2.tar.gz
- Upload date:
- Size: 37.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6c28ead6ea88e60159aebc12c0fceaf6818c088088d7ab79aed3fdad70a70d7 |
|
MD5 | 5c1edb4aa9c2e85eb5c3f151ac45477e |
|
BLAKE2b-256 | a62b3ca8f12df400cfa652345aae3d3d854d1d36bdf6064b36d633b5a41bf607 |
File details
Details for the file haruka_parser-0.7.2-py3-none-any.whl
.
File metadata
- Download URL: haruka_parser-0.7.2-py3-none-any.whl
- Upload date:
- Size: 37.6 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 | cb253a1d6fad8ccd02c056e84540144d792b8a6ca2d3b0340dd940a9406f4418 |
|
MD5 | 82a965526c35f5e9752f81d9ca7155d5 |
|
BLAKE2b-256 | d22da2d6dd94ad35b191ea48dd7d29bddc6d2bc4a5a82aa9bbc78b243b7958e3 |