Skip to content

Commit

Permalink
feature/analyze-extra-tags -> [ADDED EXCEPTION HANDLING] Handled exce…
Browse files Browse the repository at this point in the history
…ptions to resolve issue - 'ValueError: Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.'.
  • Loading branch information
SummitStha committed Dec 2, 2021
1 parent 961528c commit 03b9d4d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions seoanalyzer/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ def analyze_heading_tags(self, bs):
Analyze the heading tags and populate the headings
"""

dom = lh.fromstring(str(bs))
try:
dom = lh.fromstring(str(bs))
except ValueError as _:
dom = lh.fromstring(bs.encode('utf-8'))
for tag, xpath in HEADING_TAGS_XPATHS.items():
value = [heading.text_content() for heading in dom.xpath(xpath)]
if value:
Expand All @@ -176,7 +179,10 @@ def analyze_additional_tags(self, bs):
Analyze additional tags and populate the additional info
"""

dom = lh.fromstring(str(bs))
try:
dom = lh.fromstring(str(bs))
except ValueError as _:
dom = lh.fromstring(bs.encode('utf-8'))
for tag, xpath in ADDITIONAL_TAGS_XPATHS.items():
value = dom.xpath(xpath)
if value:
Expand Down

0 comments on commit 03b9d4d

Please sign in to comment.