summaryrefslogtreecommitdiff
path: root/searx
diff options
context:
space:
mode:
Diffstat (limited to 'searx')
-rw-r--r--searx/engines/duckduckgo.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/searx/engines/duckduckgo.py b/searx/engines/duckduckgo.py
index ac78c3b60..8a1dafbcf 100644
--- a/searx/engines/duckduckgo.py
+++ b/searx/engines/duckduckgo.py
@@ -124,7 +124,8 @@ def get_vqd(query):
value = value[: value.index('"')]
break
logger.debug("new vqd value: '%s'", value)
- cache_vqd(query, value)
+ if value is not None:
+ cache_vqd(query, value)
return value
@@ -221,13 +222,10 @@ ddg_lang_map = {
}
-def request(query, params):
-
- # request needs a vqd argument
- vqd = get_vqd(query)
-
+def quote_ddg_bangs(query):
# quote ddg bangs
query_parts = []
+
# for val in re.split(r'(\s+)', query):
for val in re.split(r'(\s+)', query):
if not val.strip():
@@ -235,7 +233,15 @@ def request(query, params):
if val.startswith('!') and external_bang.get_node(external_bang.EXTERNAL_BANGS, val[1:]):
val = f"'{val}'"
query_parts.append(val)
- query = ' '.join(query_parts)
+ return ' '.join(query_parts)
+
+
+def request(query, params):
+
+ query = quote_ddg_bangs(query)
+
+ # request needs a vqd argument
+ vqd = get_vqd(query)
eng_region = traits.get_region(params['searxng_locale'], traits.all_locale)
# eng_lang = get_ddg_lang(traits, params['searxng_locale'])