Avoid reassignment with incompatible types

This commit is contained in:
Scriptim 2024-10-25 23:52:38 +02:00
parent 2a59f76170
commit 8ff2e198e8
No known key found for this signature in database
GPG key ID: 1ABB18EA42CCAAF6

View file

@ -178,18 +178,19 @@ class KitIpdCrawler(HttpCrawler):
if resp.status != 200:
return None, None
etag = resp.headers.get("ETag")
last_modified = resp.headers.get("Last-Modified")
etag_header = resp.headers.get("ETag")
last_modified_header = resp.headers.get("Last-Modified")
if last_modified_header:
try:
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Last-Modified#directives
datetime_format = "%a, %d %b %Y %H:%M:%S GMT"
last_modified = datetime.strptime(last_modified, datetime_format)
last_modified = datetime.strptime(last_modified_header, datetime_format)
except ValueError:
# last_modified remains None
pass
return etag, last_modified
return etag_header, last_modified
async def get_page(self) -> Tuple[BeautifulSoup, str]:
async with self.session.get(self._url) as request: