From 5fd4fdb21ca591dfdcf28152ac5e32cc6ffad032 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Tue, 8 Oct 2019 08:01:17 +0000 Subject: [PATCH] Fix Tildes comments with unknown authors --- apiserver/feeds/tildes.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apiserver/feeds/tildes.py b/apiserver/feeds/tildes.py index 917425b..5f5dd11 100644 --- a/apiserver/feeds/tildes.py +++ b/apiserver/feeds/tildes.py @@ -46,7 +46,8 @@ def comment(i): return False c = {} - c['author'] = str(i.find('a', class_='link-user').string) + lu = i.find('a', class_='link-user') + c['author'] = str(lu.string if lu else 'unknown user') c['score'] = 1 c['date'] = unix(i.find('time')['datetime']) c['text'] = i.find('div', class_='comment-text').encode_contents().decode() @@ -109,7 +110,7 @@ if __name__ == '__main__': #print(self_post) #li_comment = story('gqx') #print(li_comment) - broken = story('hmi') + broken = story('hsg') print(broken) # make sure there's no self-reference