From b9e1f8c327c2c386f099f2094501e16af43a7b59 Mon Sep 17 00:00:00 2001 From: Saghalt Date: Mon, 2 Sep 2024 20:55:21 +0200 Subject: [PATCH] fix: ValueError when downloading ads without special_attributes (#330) --- src/kleinanzeigen_bot/extract.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/kleinanzeigen_bot/extract.py b/src/kleinanzeigen_bot/extract.py index 824b5aae..82e0d81d 100644 --- a/src/kleinanzeigen_bot/extract.py +++ b/src/kleinanzeigen_bot/extract.py @@ -285,12 +285,13 @@ async def _extract_category_from_ad_page(self) -> str: async def _extract_special_attributes_from_ad_page(self) -> dict[str, Any]: """ Extracts the special attributes from an ad page. + If no items are available then special_attributes is empty :return: a dictionary (possibly empty) where the keys are the attribute names, mapped to their values """ belen_conf = await self.web_execute("window.BelenConf") special_attributes_str = belen_conf["universalAnalyticsOpts"]["dimensions"]["dimension108"] - special_attributes = dict(item.split(":") for item in special_attributes_str.split("|")) + special_attributes = dict(item.split(":") for item in special_attributes_str.split("|") if ":" in item) special_attributes = {k: v for k, v in special_attributes.items() if not k.endswith('.versand_s') and k != "versand_s"} return special_attributes