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] unsplash: fix engine due to anubis bot blocking (#5907)

Bnyrofe1d6d9c48db
diff --git a/searx/engines/unsplash.py b/searx/engines/unsplash.py
index 337c8a710..7a5a72cd4 100644
--- a/searx/engines/unsplash.py
+++ b/searx/engines/unsplash.py
@@ -4,6 +4,8 @@
from urllib.parse import urlencode, urlparse, urlunparse, parse_qsl
from json import loads
+from searx.utils import searxng_useragent
+
# about
about = {
"website": 'https://unsplash.com',
@@ -31,6 +33,13 @@ def clean_url(url):
def request(query, params):
params['url'] = search_url + urlencode({'query': query, 'page': params['pageno'], 'per_page': page_size})
logger.debug("query_url --> %s", params['url'])
+
+ # common user agents (e.g. Firefox, Chrome) are blocked
+ # by Anubis (https://anubis.techaro.lol/)
+ # so we pass the searxng user agent instead, which is not
+ # commonly used by crawlers and hence not blocked
+ params["headers"]["User-Agent"] = searxng_useragent()
+
return params