summaryrefslogtreecommitdiff
path: root/searx/engines/duckduckgo.py
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2023-10-10 09:04:00 +0200
committerMarkus Heiser <markus.heiser@darmarIT.de>2023-10-10 09:12:30 +0200
commit3388441917d4e33bbfe605731dcebe149194cad3 (patch)
tree3cf62f478c01be8cf79865ceac1b6bb3bcda3bb6 /searx/engines/duckduckgo.py
parent9197efa2a734c6934494f491f9b8dcaa89e49b62 (diff)
downloadsearxng-3388441917d4e33bbfe605731dcebe149194cad3.tar.gz
searxng-3388441917d4e33bbfe605731dcebe149194cad3.zip
[fix] ddg-lite vqd value: some search terms do not have a vqd value
Some search terms do not have results and therefore no vqd value BTW: remove a leftover from 9197efa Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/engines/duckduckgo.py')
-rw-r--r--searx/engines/duckduckgo.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/searx/engines/duckduckgo.py b/searx/engines/duckduckgo.py
index e421b9cfd..3ce629eec 100644
--- a/searx/engines/duckduckgo.py
+++ b/searx/engines/duckduckgo.py
@@ -98,7 +98,12 @@ def get_vqd(query):
query_url = 'https://lite.duckduckgo.com/lite/?{args}'.format(args=urlencode({'q': query}))
res = get(query_url)
doc = lxml.html.fromstring(res.text)
- value = doc.xpath("//input[@name='vqd']/@value")[0]
+ value = doc.xpath("//input[@name='vqd']/@value")
+ if value:
+ value = value[0]
+ else:
+ # some search terms do not have results and therefore no vqd value
+ value = ''
logger.debug("new vqd value: %s", value)
cache_vqd(query, value)
return value
@@ -236,9 +241,6 @@ def request(query, params):
params['data']['s'] = offset
params['data']['dc'] = offset + 1
- # request needs a vqd argument
- params['data']['vqd'] = get_vqd(query)
-
# initial page does not have additional data in the input form
if params['pageno'] > 1: