From 7b5af420826a9744bb3ff0ec3031ffbbefdacc63 Mon Sep 17 00:00:00 2001 From: tema Date: Mon, 14 Nov 2022 17:53:04 +0200 Subject: [PATCH] Fix --- parser/utils.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/parser/utils.py b/parser/utils.py index 6733995..4c829dd 100644 --- a/parser/utils.py +++ b/parser/utils.py @@ -1,4 +1,5 @@ from bs4 import BeautifulSoup +from typing import Any def table_parser(soup: BeautifulSoup, output): #Date parser @@ -24,8 +25,10 @@ def table_parser(soup: BeautifulSoup, output): def image_parser(soup: BeautifulSoup): + image: Any + extension = ('png', 'jpg') main = soup.find("main") - image = main.select('img[src$=".png"]') - output = image[0]['src'] - - return output + for ext in extension: + image = main.select(f'img[src$=".{ext}"]') + if image: + return image[0]['src']