aboutsummaryrefslogtreecommitdiffstats
path: root/python/sandcrawler/ia.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2020-03-23 10:32:47 -0700
committerBryan Newbold <bnewbold@archive.org>2020-03-23 10:32:50 -0700
commit84eeefbd3c55ea31bcf552f9c129c0e1576717ae (patch)
treea66a381fc9535ff3ed6b3760c573b4476e3ab043 /python/sandcrawler/ia.py
parente5ad7bddbcb55471b96ce30397ed85fe98e3b098 (diff)
downloadsandcrawler-84eeefbd3c55ea31bcf552f9c129c0e1576717ae.tar.gz
sandcrawler-84eeefbd3c55ea31bcf552f9c129c0e1576717ae.zip
ingest: clean_url() in more places
Some 'cdx-error' results were due to URLs with ':' after the hostname or trailing newline ("\n") characters in the URL. This attempts to work around this categroy of error.
Diffstat (limited to 'python/sandcrawler/ia.py')
-rw-r--r--python/sandcrawler/ia.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/python/sandcrawler/ia.py b/python/sandcrawler/ia.py
index 25697be..cc176d0 100644
--- a/python/sandcrawler/ia.py
+++ b/python/sandcrawler/ia.py
@@ -18,7 +18,7 @@ from http.client import IncompleteRead
from wayback.resourcestore import ResourceStore
from gwb.loader import CDXLoaderFactory
-from .misc import b32_hex, requests_retry_session, gen_file_metadata
+from .misc import b32_hex, requests_retry_session, gen_file_metadata, clean_url
class SandcrawlerBackoffError(Exception):
"""
@@ -543,6 +543,7 @@ class WaybackClient:
if redirect_url and redirect_url.startswith("https://web.archive.org/web/"):
redirect_url = "/".join(redirect_url.split("/")[5:])
#print(redirect_url, file=sys.stderr)
+ redirect_url = clean_url(redirect_url)
if redirect_url and redirect_url.startswith("http"):
return redirect_url
else:
@@ -666,11 +667,13 @@ class WaybackClient:
next_url = domain_prefix + resource.location
else:
next_url = resource.location
+ next_url = clean_url(next_url)
else:
next_url = self.fetch_replay_redirect(
url=cdx_row.url,
datetime=cdx_row.datetime,
)
+ next_url = clean_url(next_url)
cdx_row = cdx_partial_from_row(cdx_row)
if not next_url:
print("bad redirect record: {}".format(cdx_row), file=sys.stderr)