Skip to content

Commit eeed979

Browse files
Fix captures fetching
1 parent bc7bf0b commit eeed979

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

archive_query_log/captures/__init__.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from itertools import chain
22
from typing import Iterable, Iterator
3-
from urllib.error import HTTPError
43
from urllib.parse import urljoin
54
from uuid import uuid5
65
from warnings import warn
@@ -9,7 +8,7 @@
98
from elasticsearch_dsl import Search
109
from elasticsearch_dsl.function import RandomScore
1110
from elasticsearch_dsl.query import FunctionScore, RankFeature, Term
12-
from requests import ConnectTimeout
11+
from requests import ConnectTimeout, HTTPError, Response
1312
from tqdm.auto import tqdm
1413
from web_archive_api.cdx import CdxApi, CdxMatchType
1514

@@ -105,14 +104,14 @@ def _add_captures_actions(
105104
return
106105
except HTTPError as e:
107106
ignored = False
108-
if e.status is not None:
109-
if e.status == 403:
110-
warn(RuntimeWarning(
111-
f"Unauthorized to fetch captures for source "
112-
f"domain {source.provider.domain} and "
113-
f"URL prefix {source.provider.url_path_prefix}."
114-
))
115-
ignored = True
107+
response: Response = e.response
108+
if response.status_code == 403:
109+
warn(RuntimeWarning(
110+
f"Unauthorized to fetch captures for source "
111+
f"domain {source.provider.domain} and "
112+
f"URL prefix {source.provider.url_path_prefix}."
113+
))
114+
ignored = True
116115
if not ignored:
117116
raise e
118117

0 commit comments

Comments
 (0)