From abf8589e0210947e50b07f511b151a1788ca3ea0 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 3 Nov 2020 10:53:40 +0000 Subject: [PATCH] fix sitemap --- apiserver/feeds/sitemap.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apiserver/feeds/sitemap.py b/apiserver/feeds/sitemap.py index cfb83d7..2282a5d 100644 --- a/apiserver/feeds/sitemap.py +++ b/apiserver/feeds/sitemap.py @@ -108,20 +108,20 @@ class Sitemap: if md['type'] == 'https://schema.org/NewsArticle': props = md['properties'] s['title'] = props['headline'] - if props['author']: + if 'author' in props and props['author']: s['author'] = props['author']['properties']['name'] for ld in data['json-ld']: if ld['@type'] == 'Article': s['title'] = ld['headline'] - if ld['author']: + if 'author' in ld and ld['author']: s['author'] = ld['author']['name'] return s # scratchpad so I can quickly develop the parser if __name__ == '__main__': - # site = Sitemap("https://www.stuff.co.nz/sitemap.xml") + #site = Sitemap("https://www.stuff.co.nz/sitemap.xml") site = Sitemap("https://www.nzherald.co.nz/arcio/news-sitemap/") posts = site.feed() print(posts[:1])