SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
Python bingbravedegoogleduckduckgogooglemetasearchprivacypythonqwantsearchsearch-enginesearxsearxngstartpageyahoo
[fix] pexels: circumvent botdetection by passing referer header
Bnyro20fc6fe80db0
diff --git a/requirements.txt b/requirements.txtindex 976a0312f..1a8d6d016 100644--- a/requirements.txt+++ b/requirements.txt@@ -17,4 +17,3 @@ typer==0.24.1isodate==0.7.2whitenoise==6.12.0typing-extensions==4.15.0-cloudscraper==1.2.71diff --git a/searx/engines/pexels.py b/searx/engines/pexels.pyindex 57d2d1424..aa9ace50e 100644--- a/searx/engines/pexels.py+++ b/searx/engines/pexels.py@@ -6,10 +6,8 @@ import refrom urllib.parse import urlencodefrom lxml import html-import cloudscraper-from searx.result_types import EngineResults-from searx.utils import eval_xpath_list+from searx.utils import eval_xpath_list, gen_useragentfrom searx.enginelib import EngineCachefrom searx.exceptions import SearxEngineAPIExceptionfrom searx.network import get@@ -40,6 +38,8 @@ SECRET_KEY_DB_KEY = "secret-key"CACHE: EngineCache"""Cache to store the secret API key for the engine."""+enable_http2 = False+def init(engine_settings):global CACHE # pylint: disable=global-statement@@ -47,8 +47,15 @@ def init(engine_settings):def _get_secret_key():- scraper = cloudscraper.create_scraper()- resp = scraper.get(base_url)+ resp = get(+ base_url,+ headers={+ # circumvents Cloudflare bot protections+ "User-Agent": gen_useragent(),+ "Referer": base_url,+ },+ )+if resp.status_code != 200:raise SearxEngineAPIException("failed to obtain secret key")