From f51402298ce24df8c5af13e96c7b1bb9f371d51a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20van=20Delft?= Date: Tue, 23 Jan 2024 20:07:54 +0100 Subject: [PATCH] Add try-except clause to text parsing --- heidegger_index/models.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/heidegger_index/models.py b/heidegger_index/models.py index 10afcad..b3f9f52 100644 --- a/heidegger_index/models.py +++ b/heidegger_index/models.py @@ -150,8 +150,15 @@ def load_work_text(self): + self.urn ) p_response = requests.get(p_link) - parsed_xml = BeautifulSoup(p_response.text, "html.parser") - self.perseus_content = parsed_xml.p.contents[-1].string + + try: + # TODO: URN-based parsing, or strip bibl & label contents + parsed_xml = BeautifulSoup(p_response.text, "html.parser") + perseus_content = parsed_xml.p.contents[-1].string + except AttributeError: + pass + else: + self.perseus_content = perseus_content @property def display(self):