From b03fe74f10f76b14db4dc6e45903c9bf8fdfd9ed Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Thu, 16 Jun 2022 10:28:06 -0600 Subject: [PATCH] Ensure currency link parent exists before parsing Fixes #782 --- app/utils/results.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/utils/results.py b/app/utils/results.py index a2b8083..67835eb 100644 --- a/app/utils/results.py +++ b/app/utils/results.py @@ -267,7 +267,10 @@ def check_currency(response: str) -> dict: if currency_link: while 'class' not in currency_link.attrs or \ 'ZINbbc' not in currency_link.attrs['class']: - currency_link = currency_link.parent + if currency_link.parent: + currency_link = currency_link.parent + else: + return {} currency_link = currency_link.find_all(class_='BNeawe') currency1 = currency_link[0].text currency2 = currency_link[1].text