From 0da2fafcd8b7dbe258775cb5ff4f84fa671b846f Mon Sep 17 00:00:00 2001 From: I-Al-Istannen Date: Wed, 4 Nov 2020 14:38:15 +0100 Subject: [PATCH] Fix links outside tables --- PFERD/ipd.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/PFERD/ipd.py b/PFERD/ipd.py index 33aaff1..d602e0e 100644 --- a/PFERD/ipd.py +++ b/PFERD/ipd.py @@ -86,11 +86,12 @@ class IpdCrawler: href: str = link.attrs.get("href") name = href.split("/")[-1] - modification_date: Optional[datetime.datetime] + modification_date: Optional[datetime.datetime] = None try: enclosing_row: bs4.Tag = link.findParent(name="tr") - date_text = enclosing_row.find(name="td").text - modification_date = datetime.datetime.strptime(date_text, "%d.%m.%Y") + if enclosing_row: + date_text = enclosing_row.find(name="td").text + modification_date = datetime.datetime.strptime(date_text, "%d.%m.%Y") except ValueError: modification_date = None