Created
March 24, 2021 21:20
-
-
Save boxabirds/88fbf432b756e8def8aa49a36ec4e3ba to your computer and use it in GitHub Desktop.
Simple test of trafilatura
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from trafilatura.core import bare_extraction, extract | |
from pathlib import Path | |
import json | |
from sentence_splitter import SentenceSplitter | |
html_path = Path("data") / "testfile-3.html" | |
html = html_path.read_text() | |
result_json_text = extract( | |
output_format="json", | |
filecontent=html, | |
include_images=True, | |
include_formatting=True | |
) | |
result = json.loads(result_json_text) | |
splitter = SentenceSplitter(language="en") | |
sentences = splitter.split(result["text"]) | |
print(json.dumps(result,indent=2)) | |
print("===") | |
print(json.dumps(sentences,indent=2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
testfile-3.html
is this file downloaded locally: https://lisn-tests.netlify.app/rich-content.html