mirror of
https://github.com/searxng/searxng.git
synced 2024-11-22 20:17:45 +01:00
[enh] engine selection support
This commit is contained in:
parent
e4b768b6cc
commit
9e1ded688f
@ -28,12 +28,14 @@ def make_callback(engine_name, results, callback):
|
|||||||
results.append(result)
|
results.append(result)
|
||||||
return process_callback
|
return process_callback
|
||||||
|
|
||||||
def search(query, request):
|
def search(query, request, selected_engines):
|
||||||
global engines
|
global engines
|
||||||
requests = []
|
requests = []
|
||||||
results = []
|
results = []
|
||||||
user_agent = request.headers.get('User-Agent', '')
|
user_agent = request.headers.get('User-Agent', '')
|
||||||
for ename, engine in engines.items():
|
for ename, engine in engines.items():
|
||||||
|
if ename not in selected_engines:
|
||||||
|
continue
|
||||||
headers = default_request_params()
|
headers = default_request_params()
|
||||||
headers['User-Agent'] = user_agent
|
headers['User-Agent'] = user_agent
|
||||||
request_params = engine.request(query, headers)
|
request_params = engine.request(query, headers)
|
||||||
|
@ -47,8 +47,14 @@ def index():
|
|||||||
if not request.form.get('q'):
|
if not request.form.get('q'):
|
||||||
flash('Wrong post data')
|
flash('Wrong post data')
|
||||||
return render('index.html')
|
return render('index.html')
|
||||||
|
selected_engines = []
|
||||||
|
for pd_name,pd in request.form.items():
|
||||||
|
print pd
|
||||||
|
if pd_name.startswith('engine_'):
|
||||||
|
selected_engines.append(pd_name[7:])
|
||||||
|
print selected_engines
|
||||||
query = request.form['q']
|
query = request.form['q']
|
||||||
results = search(query, request)
|
results = search(query, request, selected_engines)
|
||||||
return render('results.html', results=results, q=query)
|
return render('results.html', results=results, q=query)
|
||||||
return render('index.html')
|
return render('index.html')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user