diff --git a/livie.py b/livie.py index 9f21ed3..515ed12 100644 --- a/livie.py +++ b/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