[fix] google: switch to using GSA for iPhone useragent

This commit is contained in:
mg95
2026-01-11 17:21:01 +02:00
committed by GitHub
parent 44405bd03c
commit cf74e1d9e9
8 changed files with 500 additions and 26 deletions

View File

@@ -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"""