diff options
author | Markus Heiser <markus.heiser@darmarit.de> | 2023-12-23 19:39:05 +0100 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarIT.de> | 2023-12-24 08:28:32 +0100 |
commit | 6df922b9dad281b025419e05db269c02e2b263cc (patch) | |
tree | 865444d4cb26b2970a673fc3663f1b98aabcb665 /searx/engines/google.py | |
parent | d6ac2b5a55c31824380ec109e430e1cec1f4d19f (diff) | |
download | searxng-6df922b9dad281b025419e05db269c02e2b263cc.tar.gz searxng-6df922b9dad281b025419e05db269c02e2b263cc.zip |
[fix] fetch_traits of google and zlibrary
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/engines/google.py')
-rw-r--r-- | searx/engines/google.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/searx/engines/google.py b/searx/engines/google.py index 90b58e270..0bf7fdb01 100644 --- a/searx/engines/google.py +++ b/searx/engines/google.py @@ -430,14 +430,13 @@ def fetch_traits(engine_traits: EngineTraits, add_domains: bool = True): if not resp.ok: # type: ignore raise RuntimeError("Response from Google's preferences is not OK.") - dom = html.fromstring(resp.text) # type: ignore + dom = html.fromstring(resp.text.replace('<?xml version="1.0" encoding="UTF-8"?>', '')) # supported language codes lang_map = {'no': 'nb'} - for x in eval_xpath_list(dom, '//*[@id="langSec"]//input[@name="lr"]'): - - eng_lang = x.get("value").split('_')[-1] + for x in eval_xpath_list(dom, "//select[@name='hl']/option"): + eng_lang = x.get("value") try: locale = babel.Locale.parse(lang_map.get(eng_lang, eng_lang), sep='-') except babel.UnknownLocaleError: @@ -457,7 +456,7 @@ def fetch_traits(engine_traits: EngineTraits, add_domains: bool = True): # supported region codes - for x in eval_xpath_list(dom, '//*[@name="region"]/..//input[@name="region"]'): + for x in eval_xpath_list(dom, "//select[@name='gl']/option"): eng_country = x.get("value") if eng_country in skip_countries: |