From 82adde6b9ce7576734ede93d6217f4aafe59aa58 Mon Sep 17 00:00:00 2001 From: Helias Date: Mon, 19 Feb 2024 00:05:26 +0100 Subject: [PATCH] fix: handle potential errors --- module/scraper/scraper.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/module/scraper/scraper.py b/module/scraper/scraper.py index e16de15..e9fb78e 100644 --- a/module/scraper/scraper.py +++ b/module/scraper/scraper.py @@ -22,7 +22,12 @@ def find_info(article: any) -> tuple: # finds the info of an article href_article = article.find_all('a', href=True, title=True) - title_article = href_article[1].get_text() + + if len(href_article) > 1: + title_article = href_article[1].get_text() + else: + title_article = None + div_article = article.find('div', {'class': 'slide-meta'}) link_article = article.find('a') link_article = link_article['href']