mirror of
https://github.com/searxng/searxng
synced 2024-11-09 01:10:26 +00:00
[refactor] duckduckgo: use extr helper function in get_vqd
This commit is contained in:
parent
7be468d213
commit
1fe13d0ba4
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user