From 9e1ded688fc1c91c48ae13c071c1971bf006fca6 Mon Sep 17 00:00:00 2001 From: asciimoo Date: Tue, 15 Oct 2013 22:18:08 +0200 Subject: [PATCH] [enh] engine selection support --- searx/engines/__init__.py | 4 +++- searx/webapp.py | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py index 86fa50d2a..1b47a9f5f 100644 --- a/searx/engines/__init__.py +++ b/searx/engines/__init__.py @@ -28,12 +28,14 @@ def make_callback(engine_name, results, callback): results.append(result) return process_callback -def search(query, request): +def search(query, request, selected_engines): global engines requests = [] results = [] user_agent = request.headers.get('User-Agent', '') for ename, engine in engines.items(): + if ename not in selected_engines: + continue headers = default_request_params() headers['User-Agent'] = user_agent request_params = engine.request(query, headers) diff --git a/searx/webapp.py b/searx/webapp.py index 1c88bcc6f..bfef5f6b6 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -47,8 +47,14 @@ def index(): if not request.form.get('q'): flash('Wrong post data') 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'] - results = search(query, request) + results = search(query, request, selected_engines) return render('results.html', results=results, q=query) return render('index.html')