From 1fe13d0ba4dea086654b30746fa3cc8f2645606f Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 14 Jun 2024 14:39:22 +0200 Subject: [PATCH] [refactor] duckduckgo: use extr helper function in get_vqd --- searx/engines/duckduckgo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/searx/engines/duckduckgo.py b/searx/engines/duckduckgo.py index fced014c1..feaa719d9 100644 --- a/searx/engines/duckduckgo.py +++ b/searx/engines/duckduckgo.py @@ -24,6 +24,7 @@ from searx.utils import ( from searx.network import get # see https://github.com/searxng/searxng/issues/762 from searx import redisdb from searx.enginelib.traits import EngineTraits +from searx.utils import extr if TYPE_CHECKING: import logging @@ -120,8 +121,7 @@ def get_vqd(query): for script in doc.xpath("//script[@type='text/javascript']"): script = script.text if 'vqd="' in script: - value = script[script.index('vqd="') + 5 :] - value = value[: value.index('"')] + value = extr(script, 'vqd="', '"') break logger.debug("new vqd value: '%s'", value) if value is not None: @@ -393,7 +393,7 @@ def fetch_traits(engine_traits: EngineTraits): """ # pylint: disable=too-many-branches, too-many-statements, disable=import-outside-toplevel - from searx.utils import extr, js_variable_to_python + from searx.utils import js_variable_to_python # fetch regions