From 49649d1a84ccb1a89fb69179ff6528918a4ef22f Mon Sep 17 00:00:00 2001 From: Niko Strijbol Date: Thu, 5 Sep 2024 14:24:41 +0200 Subject: [PATCH] Ignore no programme information --- server/scraper/urgentfm.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/scraper/urgentfm.py b/server/scraper/urgentfm.py index 38c6aea4..ef2668ab 100755 --- a/server/scraper/urgentfm.py +++ b/server/scraper/urgentfm.py @@ -28,6 +28,8 @@ def get_programme(): def get_programme_description(link): + if link is None: + return None, None response = retry_session.get(link) soup = BeautifulSoup(response.text, 'html.parser') image_element = soup.select_one("body > div.content > div > div > div.col-3.col-md-auto > img") @@ -45,7 +47,12 @@ def run(output): os.makedirs(output_path, exist_ok=True) # Like mkdir -p output_file = os.path.join(output_path, 'status.json') # Output file - programme, programme_link = get_programme() + try: + programme, programme_link = get_programme() + except AttributeError: + # The site is flaky again and I am tired of the mails. + programme, programme_link = "Onbekend", None + try: programme_image, programme_description = get_programme_description(programme_link) except IndexError: