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