Skip to content

SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.

[fix] public domain image archive: fails to extract API url

Bnyro3066bc19ebe9
diff --git a/searx/engines/public_domain_image_archive.py b/searx/engines/public_domain_image_archive.py
index 81beb418d..0a528ef15 100644
--- a/searx/engines/public_domain_image_archive.py
+++ b/searx/engines/public_domain_image_archive.py
@@ -1,6 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""Public domain image archive"""
+import re
+
from urllib.parse import urlencode, urlparse, urlunparse, parse_qsl
from json import dumps
@@ -49,6 +51,8 @@ paging = True
__CACHED_API_URL = None
+_API_URL_RE = re.compile(r"\"(https://.*?/search-proxy)\"")
+
def _clean_url(url):
parsed = urlparse(url)
@@ -74,11 +78,12 @@ def _get_algolia_api_url():
if resp.status_code != 200:
raise LookupError("Failed to obtain AWS api url for PDImageArchive")
- api_url = extr(resp.text, 'const r="', '"', default=None)
-
- if api_url is None:
+ api_url_match = _API_URL_RE.search(resp.text)
+ if api_url_match is None:
raise LookupError("Couldn't obtain AWS api url for PDImageArchive")
+ api_url = api_url_match.group(1)
+
__CACHED_API_URL = api_url
return api_url