Ensure currency link parent exists before parsing

Fixes #782
main
Ben Busby 2022-06-16 10:28:06 -06:00
parent 2600ad5a05
commit b03fe74f10
No known key found for this signature in database
GPG Key ID: B9B7231E01D924A1
1 changed files with 4 additions and 1 deletions

View File

@ -267,7 +267,10 @@ def check_currency(response: str) -> dict:
if currency_link: if currency_link:
while 'class' not in currency_link.attrs or \ while 'class' not in currency_link.attrs or \
'ZINbbc' not in currency_link.attrs['class']: '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') currency_link = currency_link.find_all(class_='BNeawe')
currency1 = currency_link[0].text currency1 = currency_link[0].text
currency2 = currency_link[1].text currency2 = currency_link[1].text