Check noneType
This commit is contained in:
parent
1dbd4a11e3
commit
45cccd67a9
19
livie.py
19
livie.py
@ -15,14 +15,23 @@ FIRST = True
|
||||
|
||||
articles = SOUP.find_all('article', class_="item-box")
|
||||
|
||||
|
||||
def check(label):
|
||||
if label is None:
|
||||
data = 'Unknown'
|
||||
else:
|
||||
data = label.text
|
||||
return data
|
||||
|
||||
|
||||
for article in articles:
|
||||
try:
|
||||
title = article.h4.text
|
||||
title = check(article.h4)
|
||||
link = article.a['href'].replace('/', '', 1)
|
||||
author = article.address.text
|
||||
time = article.p.text
|
||||
uploaded = article.span.text
|
||||
views = article.find('div', class_="views").text
|
||||
author = check(article.address)
|
||||
time = check(article.p)
|
||||
uploaded = check(article.span)
|
||||
views = check(article.find('div', class_="views"))
|
||||
|
||||
except TypeError:
|
||||
continue
|
||||
|
Loading…
x
Reference in New Issue
Block a user