diff options
| author | mg95 <git@esen.gay> | 2026-01-11 17:21:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-11 16:21:01 +0100 |
| commit | cf74e1d9e9ad662aef450ddd79aedee43554dc3c (patch) | |
| tree | 4848c9fbcd31c254d14705d47328b2c534781e32 /searx/utils.py | |
| parent | 44405bd03c14bd62bc68f39dfca7b5d56a97eb14 (diff) | |
Diffstat (limited to 'searx/utils.py')
| -rw-r--r-- | searx/utils.py | 10 |
1 files changed, 9 insertions, 1 deletions
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""" |