summaryrefslogtreecommitdiff
path: root/searx/autocomplete.py
diff options
context:
space:
mode:
authorAllen <64094914+allendema@users.noreply.github.com>2022-01-02 23:05:49 +0100
committerMarkus Heiser <markus.heiser@darmarit.de>2022-01-21 14:39:10 +0100
commitb8c98c4c0d716c1e1c3a7f26788a012a41e59dbe (patch)
tree3abf4254e404076a5d4710bae6bb4e77a4bbbca5 /searx/autocomplete.py
parentf3d4b25e739164ea6af087379536b3ef3538d63c (diff)
downloadsearxng-b8c98c4c0d716c1e1c3a7f26788a012a41e59dbe.tar.gz
searxng-b8c98c4c0d716c1e1c3a7f26788a012a41e59dbe.zip
[enh] Add autocompleter from Brave
Raw response example: https://search.brave.com/api/suggest?q=how%20to:%20with%20j Headers are needed in order to get a 200 response, thus Searx user-agent is used. Other URL param could be '&rich=false' or '&rich=true'. Cherry-pick: https://github.com/allendema/searx/commit/71786bf9cb6fbb175a054692e6951e77769aac1b
Diffstat (limited to 'searx/autocomplete.py')
-rw-r--r--searx/autocomplete.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/searx/autocomplete.py b/searx/autocomplete.py
index b8d272c32..6c69ff7c5 100644
--- a/searx/autocomplete.py
+++ b/searx/autocomplete.py
@@ -36,6 +36,20 @@ def get(*args, **kwargs):
return http_get(*args, **kwargs)
+def brave(query, lang):
+ # brave search autocompleter
+ url = 'https://search.brave.com/api/suggest?{query}'
+ resp = get(url.format(query=urlencode({'q': query})))
+
+ results = []
+
+ if resp.ok:
+ data = loads(resp.text)
+ for item in data[1]:
+ results.append(item)
+ return results
+
+
def dbpedia(query, lang):
# dbpedia autocompleter, no HTTPS
autocomplete_url = 'https://lookup.dbpedia.org/api/search.asmx/KeywordSearch?'
@@ -128,6 +142,7 @@ backends = {
'swisscows': swisscows,
'qwant': qwant,
'wikipedia': wikipedia,
+ 'brave': brave,
}