From cf74e1d9e9ad662aef450ddd79aedee43554dc3c Mon Sep 17 00:00:00 2001 From: mg95 Date: Sun, 11 Jan 2026 17:21:01 +0200 Subject: [fix] google: switch to using GSA for iPhone useragent --- searx/utils.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'searx/utils.py') diff --git a/searx/utils.py b/searx/utils.py index 4bbf8fb94..7d8a07e95 100644 --- a/searx/utils.py +++ b/searx/utils.py @@ -25,7 +25,7 @@ from lxml.etree import XPath, XPathError, XPathSyntaxError from lxml.etree import ElementBase, _Element # pyright: ignore[reportPrivateUsage] from searx import settings -from searx.data import USER_AGENTS, data_dir +from searx.data import USER_AGENTS, data_dir, gsa_useragents_loader from searx.version import VERSION_TAG from searx.sxng_locales import sxng_locales from searx.exceptions import SearxXPathSyntaxException, SearxEngineXPathException @@ -92,6 +92,14 @@ def gen_useragent(os_string: str | None = None) -> str: ) +def gen_gsa_useragent() -> str: + """Return a random GSA User Agent suitable for Google + + See searx/data/gsa_useragents.txt + """ + return choice(gsa_useragents_loader()) + + class HTMLTextExtractor(HTMLParser): """Internal class to extract text from HTML""" -- cgit v1.2.3