logo

searx

Unnamed repository; edit this file 'description' to name the repository.
commit: 70278567ecacd1632dfdfdff6dbcc0f14a8fab02
parent: d2a952ecdf5b4580fcb1ee21b1a2cb9a02873685
Author: asciimoo <asciimoo@gmail.com>
Date:   Mon,  4 Nov 2013 00:18:07 +0100

[mod] searching by selected engines

Diffstat:

searx/engines/__init__.py | 9+--------
searx/webapp.py | 13+++++++++++--
2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py @@ -97,20 +97,13 @@ def make_callback(engine_name, results, callback, params): results[engine_name] = cb_res return process_callback -def search(query, request, selected_categories): +def search(query, request, selected_engines): global engines, categories, number_of_searches requests = [] results = {} - selected_engines = [] number_of_searches += 1 user_agent = request.headers.get('User-Agent', '') - if not len(selected_categories): - selected_categories = ['general'] - - for categ in selected_categories: - selected_engines.extend({'category': categ, 'name': x.name} for x in categories[categ]) - for selected_engine in selected_engines: if selected_engine['name'] not in engines: continue diff --git a/searx/webapp.py b/searx/webapp.py @@ -65,6 +65,9 @@ def index(): request_data = request.args if not request_data.get('q'): return render('index.html') + + query = request_data['q'].encode('utf-8') + selected_categories = [] for pd_name,pd in request_data.items(): if pd_name.startswith('category_'): @@ -77,8 +80,14 @@ def index(): for ccateg in cookie_categories: if ccateg in categories: selected_categories.append(ccateg) - query = request_data['q'].encode('utf-8') - results = search(query, request, selected_categories) + if not len(selected_categories): + selected_categories = ['general'] + + selected_engines = [] + for categ in selected_categories: + selected_engines.extend({'category': categ, 'name': x.name} for x in categories[categ]) + + results = search(query, request, selected_engines) for result in results: if len(result['url']) > 74: result['pretty_url'] = result['url'][:35] + '[..]' + result['url'][-35:]