From 423f1fa6637b96ddff4c6ecc3a11fc039c46733d Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 11 Aug 2024 21:24:52 +0300 Subject: [PATCH] Fix(bkmk_ph_lxml): Catch `ParserError` --- parse_html/bkmk_ph_lxml.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/parse_html/bkmk_ph_lxml.py b/parse_html/bkmk_ph_lxml.py index 7af98e7..eb8ecc6 100644 --- a/parse_html/bkmk_ph_lxml.py +++ b/parse_html/bkmk_ph_lxml.py @@ -12,6 +12,7 @@ __all__ = ['parse_html'] import re +from lxml.etree import ParserError from lxml.html import fromstring from .bkmk_ph_util import HTMLParser @@ -39,6 +40,8 @@ def parse_html(html_text, charset=None, log=None): return None else: raise + except ParserError: + return None title = html_tree.findtext('head/title') if title is None: -- 2.39.5