mirror of
https://github.com/Garmelon/PFERD.git
synced 2026-04-12 15:35:05 +02:00
Avoid reassignment with incompatible types
This commit is contained in:
parent
2a59f76170
commit
8ff2e198e8
1 changed files with 11 additions and 10 deletions
|
|
@ -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")
|
||||
|
||||
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)
|
||||
except ValueError:
|
||||
# last_modified remains None
|
||||
pass
|
||||
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_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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue