Check noneType

This commit is contained in:
Jesús 2021-01-15 20:33:16 -05:00
parent 1dbd4a11e3
commit 45cccd67a9
No known key found for this signature in database
GPG Key ID: F6EE7BC59A315766

View File

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