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")
|
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:
|
for article in articles:
|
||||||
try:
|
try:
|
||||||
title = article.h4.text
|
title = check(article.h4)
|
||||||
link = article.a['href'].replace('/', '', 1)
|
link = article.a['href'].replace('/', '', 1)
|
||||||
author = article.address.text
|
author = check(article.address)
|
||||||
time = article.p.text
|
time = check(article.p)
|
||||||
uploaded = article.span.text
|
uploaded = check(article.span)
|
||||||
views = article.find('div', class_="views").text
|
views = check(article.find('div', class_="views"))
|
||||||
|
|
||||||
except TypeError:
|
except TypeError:
|
||||||
continue
|
continue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user