From efa06c9e336cf78145c48f2bdad3b52ed283805f Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Tue, 30 Jun 2020 11:23:15 +0100 Subject: [PATCH] Avoid crash on empty catalog page --- depicts/wd_catalog.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/depicts/wd_catalog.py b/depicts/wd_catalog.py index 5b2fe7b..41ac34c 100644 --- a/depicts/wd_catalog.py +++ b/depicts/wd_catalog.py @@ -154,10 +154,11 @@ def check_catalog(entity, catalog): return html = get_catalog_url(catalog_url) - description = get_description_from_page(html) - if description: - catalog['description'] = description, - return + if html: + description = get_description_from_page(html) + if description: + catalog['description'] = description + return for property_id in sorted(catalog_ids): if property_id == 'P350': @@ -208,6 +209,8 @@ def get_catalog_from_artwork(entity): return catalog def get_description_from_page(html): + if not html: + return root = lxml.html.fromstring(html) div = root.find('.//div[@itemprop="description"]') if div is not None: