From 37b8e7e41f89fd0196c6bb00fe06af9c94117438 Mon Sep 17 00:00:00 2001 From: Arthur Taylor Date: Sun, 15 Dec 2024 13:52:30 +0100 Subject: [PATCH] Fix linter errors for Immowelt crawler --- flathunter/crawler/immowelt.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/flathunter/crawler/immowelt.py b/flathunter/crawler/immowelt.py index 4117607..a21c9ce 100644 --- a/flathunter/crawler/immowelt.py +++ b/flathunter/crawler/immowelt.py @@ -57,21 +57,22 @@ def extract_data(self, soup: BeautifulSoup): for adv in advertisements: try: title = adv.find("div", {"class": "css-1cbj9xw"}).text - except: + except AttributeError: title = "" try: price = adv.find( "div", attrs={"data-testid": "cardmfe-price-testid"}).text - except: + except AttributeError: price = "" try: - descriptions = adv.find("div", attrs={"data-testid": "cardmfe-keyfacts-testid"}).children + descriptions = adv.find("div", + attrs={"data-testid": "cardmfe-keyfacts-testid"}).children descriptions = [result.text for result in descriptions] - except: + except AttributeError: descriptions = [] - + size = list(filter(lambda x: "m²" in x, descriptions)) try: size = size[0] @@ -122,4 +123,4 @@ def extract_data(self, soup: BeautifulSoup): entries.append(details) logger.debug('Number of entries found: %d', len(entries)) - return entries \ No newline at end of file + return entries