|
@@ -57,17 +57,17 @@ def searx_bang(full_query):
|
57
|
57
|
# check if query starts with categorie name
|
58
|
58
|
for categorie in categories:
|
59
|
59
|
if categorie.startswith(engine_query):
|
60
|
|
- results.append(first_char+'{categorie}'.format(categorie=categorie))
|
|
60
|
+ results.append(first_char + '{categorie}'.format(categorie=categorie))
|
61
|
61
|
|
62
|
62
|
# check if query starts with engine name
|
63
|
63
|
for engine in engines:
|
64
|
64
|
if engine.startswith(engine_query.replace('_', ' ')):
|
65
|
|
- results.append(first_char+'{engine}'.format(engine=engine.replace(' ', '_')))
|
|
65
|
+ results.append(first_char + '{engine}'.format(engine=engine.replace(' ', '_')))
|
66
|
66
|
|
67
|
67
|
# check if query starts with engine shortcut
|
68
|
68
|
for engine_shortcut in engine_shortcuts:
|
69
|
69
|
if engine_shortcut.startswith(engine_query):
|
70
|
|
- results.append(first_char+'{engine_shortcut}'.format(engine_shortcut=engine_shortcut))
|
|
70
|
+ results.append(first_char + '{engine_shortcut}'.format(engine_shortcut=engine_shortcut))
|
71
|
71
|
|
72
|
72
|
# check if current query stats with :bang
|
73
|
73
|
elif first_char == ':':
|
|
@@ -112,7 +112,7 @@ def searx_bang(full_query):
|
112
|
112
|
|
113
|
113
|
def dbpedia(query):
|
114
|
114
|
# dbpedia autocompleter, no HTTPS
|
115
|
|
- autocomplete_url = 'http://lookup.dbpedia.org/api/search.asmx/KeywordSearch?' # noqa
|
|
115
|
+ autocomplete_url = 'http://lookup.dbpedia.org/api/search.asmx/KeywordSearch?'
|
116
|
116
|
|
117
|
117
|
response = get(autocomplete_url
|
118
|
118
|
+ urlencode(dict(QueryString=query)))
|
|
@@ -139,7 +139,7 @@ def duckduckgo(query):
|
139
|
139
|
|
140
|
140
|
def google(query):
|
141
|
141
|
# google autocompleter
|
142
|
|
- autocomplete_url = 'https://suggestqueries.google.com/complete/search?client=toolbar&' # noqa
|
|
142
|
+ autocomplete_url = 'https://suggestqueries.google.com/complete/search?client=toolbar&'
|
143
|
143
|
|
144
|
144
|
response = get(autocomplete_url
|
145
|
145
|
+ urlencode(dict(q=query)))
|
|
@@ -153,9 +153,20 @@ def google(query):
|
153
|
153
|
return results
|
154
|
154
|
|
155
|
155
|
|
|
156
|
+def startpage(query):
|
|
157
|
+ # wikipedia autocompleter
|
|
158
|
+ url = 'https://startpage.com/do/suggest?{query}'
|
|
159
|
+
|
|
160
|
+ resp = get(url.format(query=urlencode({'query': query}))).text.split('\n')
|
|
161
|
+ print resp
|
|
162
|
+ if len(resp) > 1:
|
|
163
|
+ return resp
|
|
164
|
+ return []
|
|
165
|
+
|
|
166
|
+
|
156
|
167
|
def wikipedia(query):
|
157
|
168
|
# wikipedia autocompleter
|
158
|
|
- url = 'https://en.wikipedia.org/w/api.php?action=opensearch&{0}&limit=10&namespace=0&format=json' # noqa
|
|
169
|
+ url = 'https://en.wikipedia.org/w/api.php?action=opensearch&{0}&limit=10&namespace=0&format=json'
|
159
|
170
|
|
160
|
171
|
resp = loads(get(url.format(urlencode(dict(search=query)))).text)
|
161
|
172
|
if len(resp) > 1:
|
|
@@ -166,5 +177,6 @@ def wikipedia(query):
|
166
|
177
|
backends = {'dbpedia': dbpedia,
|
167
|
178
|
'duckduckgo': duckduckgo,
|
168
|
179
|
'google': google,
|
|
180
|
+ 'startpage': startpage,
|
169
|
181
|
'wikipedia': wikipedia
|
170
|
182
|
}
|