Fix Tildes comments with unknown authors

This commit is contained in:
Tanner Collin 2019-10-08 08:01:17 +00:00
parent 19e9a80be1
commit 5fd4fdb21c

View File

@ -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