summaryrefslogtreecommitdiff
path: root/searx/data/__init__.py
diff options
context:
space:
mode:
authormg95 <git@esen.gay>2026-01-11 17:21:01 +0200
committerGitHub <noreply@github.com>2026-01-11 16:21:01 +0100
commitcf74e1d9e9ad662aef450ddd79aedee43554dc3c (patch)
tree4848c9fbcd31c254d14705d47328b2c534781e32 /searx/data/__init__.py
parent44405bd03c14bd62bc68f39dfca7b5d56a97eb14 (diff)
[fix] google: switch to using GSA for iPhone useragentHEADmaster
Diffstat (limited to 'searx/data/__init__.py')
-rw-r--r--searx/data/__init__.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/searx/data/__init__.py b/searx/data/__init__.py
index fc3031680..ae2d2b5a8 100644
--- a/searx/data/__init__.py
+++ b/searx/data/__init__.py
@@ -6,7 +6,7 @@ make data.all
"""
# pylint: disable=invalid-name
-__all__ = ["ahmia_blacklist_loader", "data_dir", "get_cache"]
+__all__ = ["ahmia_blacklist_loader", "gsa_useragents_loader", "data_dir", "get_cache"]
import json
import typing as t
@@ -63,6 +63,7 @@ lazy_globals = {
"ENGINE_TRAITS": None,
"LOCALES": None,
"TRACKER_PATTERNS": TrackerPatternsDB(),
+ "GSA_USER_AGENTS": None,
}
data_json_files = {
@@ -105,3 +106,24 @@ def ahmia_blacklist_loader() -> list[str]:
"""
with open(data_dir / 'ahmia_blacklist.txt', encoding='utf-8') as f:
return f.read().split()
+
+
+def gsa_useragents_loader() -> list[str]:
+ """Load data from `gsa_useragents.txt` and return a list of user agents
+ suitable for Google. The user agents are fetched by::
+
+ searxng_extra/update/update_gsa_useragents.py
+
+ This function is used by :py:mod:`searx.engines.google`.
+
+ """
+ data = lazy_globals["GSA_USER_AGENTS"]
+ if data is not None:
+ return data
+
+ log.debug("init searx.data.%s", "GSA_USER_AGENTS")
+
+ with open(data_dir / 'gsa_useragents.txt', encoding='utf-8') as f:
+ lazy_globals["GSA_USER_AGENTS"] = f.read().splitlines()
+
+ return lazy_globals["GSA_USER_AGENTS"]