diff --git a/flathunter/crawler/immowelt.py b/flathunter/crawler/immowelt.py index 4117607e..a21c9ced 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