From cb8e4dc4e96f21ac46ed49ba235400e11f757257 Mon Sep 17 00:00:00 2001 From: Joe Joiner <2454320+joejoinerr@users.noreply.github.com> Date: Wed, 11 May 2022 16:04:46 +0100 Subject: [PATCH] Fix bug with handling of missing organic link snippet --- valueserp/serp/models.py | 2 +- valueserp/serp/web.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/valueserp/serp/models.py b/valueserp/serp/models.py index 1bd8e61..c29c79d 100644 --- a/valueserp/serp/models.py +++ b/valueserp/serp/models.py @@ -9,7 +9,7 @@ class OrganicLink: title: str = dataclasses.field(repr=False) url: str url_displayed: str = dataclasses.field(repr=False) - description: str = dataclasses.field(repr=False) + description: Optional[str] = dataclasses.field(default=None, repr=False) date: Optional[str] = dataclasses.field(default=None, repr=False) diff --git a/valueserp/serp/web.py b/valueserp/serp/web.py index 630ca97..edef066 100644 --- a/valueserp/serp/web.py +++ b/valueserp/serp/web.py @@ -41,7 +41,7 @@ def links(self) -> Optional[List[OrganicLink]]: title = link['title'] url = link['link'] url_displayed = link['displayed_link'] - description = link['snippet'] + description = link.get('snippet') date = link.get('date') links.append(OrganicLink(position=position, block_position=block_position,