|
@@ -161,6 +161,23 @@ def startpage(query):
|
161
|
161
|
return []
|
162
|
162
|
|
163
|
163
|
|
|
164
|
+def qwant(query):
|
|
165
|
+ # qwant autocompleter (additional parameter : lang=en_en&count=xxx )
|
|
166
|
+ url = 'https://api.qwant.com/api/suggest?{query}'
|
|
167
|
+
|
|
168
|
+ resp = get(url.format(query=urlencode({'q': query})))
|
|
169
|
+
|
|
170
|
+ results = []
|
|
171
|
+
|
|
172
|
+ if resp.ok:
|
|
173
|
+ data = loads(resp.text)
|
|
174
|
+ if data['status'] == 'success':
|
|
175
|
+ for item in data['data']['items']:
|
|
176
|
+ results.append(item['value'])
|
|
177
|
+
|
|
178
|
+ return results
|
|
179
|
+
|
|
180
|
+
|
164
|
181
|
def wikipedia(query):
|
165
|
182
|
# wikipedia autocompleter
|
166
|
183
|
url = 'https://en.wikipedia.org/w/api.php?action=opensearch&{0}&limit=10&namespace=0&format=json'
|
|
@@ -175,5 +192,6 @@ backends = {'dbpedia': dbpedia,
|
175
|
192
|
'duckduckgo': duckduckgo,
|
176
|
193
|
'google': google,
|
177
|
194
|
'startpage': startpage,
|
|
195
|
+ 'qwant': qwant,
|
178
|
196
|
'wikipedia': wikipedia
|
179
|
197
|
}
|