summaryrefslogtreecommitdiff
path: root/searx/autocomplete.py
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2014-09-07 23:56:06 +0200
committerAdam Tauber <asciimoo@gmail.com>2014-09-07 23:56:06 +0200
commitcd3a52e18965a3077b4fad86f327f772e02b5a6a (patch)
tree41c129ed999727b95cb166c52758dd863d53cd2c /searx/autocomplete.py
parent1e99cf2a0e541a3d2df0104d64fadf955bbccc20 (diff)
downloadsearxng-cd3a52e18965a3077b4fad86f327f772e02b5a6a.tar.gz
searxng-cd3a52e18965a3077b4fad86f327f772e02b5a6a.zip
[enh] duckduckgo autocomplete added
Diffstat (limited to 'searx/autocomplete.py')
-rw-r--r--searx/autocomplete.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/searx/autocomplete.py b/searx/autocomplete.py
index 1726a8c3d..a36dfaf54 100644
--- a/searx/autocomplete.py
+++ b/searx/autocomplete.py
@@ -21,6 +21,16 @@ def dbpedia(query):
return results
+def duckduckgo(query):
+ # wikipedia autocompleter
+ url = 'https://ac.duckduckgo.com/ac/?{0}&type=list'
+
+ resp = loads(get(url.format(urlencode(dict(q=query)))).text)
+ if len(resp) > 1:
+ return resp[1]
+ return []
+
+
def google(query):
# google autocompleter
autocomplete_url = 'http://suggestqueries.google.com/complete/search?client=toolbar&' # noqa
@@ -48,6 +58,7 @@ def wikipedia(query):
backends = {'dbpedia': dbpedia,
+ 'duckduckgo': duckduckgo,
'google': google,
'wikipedia': wikipedia
}