From b6fc1546160285a2e0049d20cbd7e64269db1875 Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Sat, 24 Dec 2016 22:23:36 +0100 Subject: [PATCH 1/2] [enh] add searx engine --- searx/engines/searx_engine.py | 57 +++++++++++++++++++++++++++++++++++ searx/settings.yml | 8 +++++ 2 files changed, 65 insertions(+) create mode 100644 searx/engines/searx_engine.py diff --git a/searx/engines/searx_engine.py b/searx/engines/searx_engine.py new file mode 100644 index 000000000..91c264498 --- /dev/null +++ b/searx/engines/searx_engine.py @@ -0,0 +1,57 @@ +""" + Searx (all) + + @website https://github.com/asciimoo/searx + @provide-api yes (https://asciimoo.ithub.io/searx/dev/search_api.html) + + @using-api yes + @results JSON + @stable yes (using api) + @parse url, title, content +""" + +from json import loads +from searx.engines import categories as searx_categories + + +categories = searx_categories.keys() + +# search-url +instance_urls = [] +instance_index = 0 + + +# do search-request +def request(query, params): + global instance_index + params['url'] = instance_urls[instance_index % len(instance_urls)] + params['method'] = 'POST' + + instance_index += 1 + + params['data'] = { + 'q': query, + 'pageno': params['pageno'], + 'language': params['language'], + 'time_range': params['time_range'], + 'category': params['category'], + 'format': 'json' + } + + return params + + +# get response from search-request +def response(resp): + + response_json = loads(resp.text) + results = response_json['results'] + + for i in ('answers', 'infoboxes'): + results.extend(response_json[i]) + + results.extend({'suggestion': s} for s in response_json['suggestions']) + + results.append({'number_of_results': response_json['number_of_results']}) + + return results diff --git a/searx/settings.yml b/searx/settings.yml index 527c80829..62c6b953e 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -441,6 +441,14 @@ engines: shortcut : scc disabled : True +# - name : searx +# engine : searx_engine +# shortcut : se +# instance_urls : +# - http://127.0.0.1:8888/ +# - ... +# disabled : True + - name : spotify engine : spotify shortcut : stf From 07448e15e439dfee1d531ab9d1fd3aab15af5253 Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Sun, 25 Dec 2016 09:34:17 +0100 Subject: [PATCH 2/2] [fix] disable etymonline by default - closes #789 --- searx/settings.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/searx/settings.yml b/searx/settings.yml index 62c6b953e..01ac69de4 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -164,6 +164,7 @@ engines: suggestion_xpath : //a[@class="crossreference"] first_page_num : 0 shortcut : et + disabled : True # api-key required: http://www.faroo.com/hp/api/api.html#key # - name : faroo