Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Misbehavior of HTML Parsing #349

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions juriscraper/lib/html_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def get_html5_parsed_text(text):
:param text: The html of the document
:return: an lxml.HtmlElement object
"""

# text = __filter_printable(text)
parsed = html5parser.document_fromstring(text.encode("utf-8"))
return fromstring(tostring(parsed, encoding="unicode"))

Expand Down Expand Up @@ -271,3 +273,7 @@ def fix_links_in_lxml_tree(link, keep_anchors=False):
return url
else:
return url.split("#")[0]


def __filter_printable(text):
return re.sub(r"[\x00-\x1F\x7F]", "", text)
Loading