Skip to content

Commit

Permalink
fix: ValueError when downloading ads without special_attributes (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
Saghalt authored Sep 2, 2024
1 parent 3154005 commit b9e1f8c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/kleinanzeigen_bot/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit b9e1f8c

Please sign in to comment.