diff options
author | neodarz <neodarz@neodarz.net> | 2019-01-17 21:37:46 +0100 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2019-01-17 21:37:46 +0100 |
commit | 1e9c7b9daac9bdee0822b66efdf607eed1e24452 (patch) | |
tree | 4ca0ec5c1d2c66c2ac530b73303812851d958629 /src | |
parent | fe8b741fc804a086aeb52abef474468721c667e0 (diff) | |
download | ryzomcore_searx-1e9c7b9daac9bdee0822b66efdf607eed1e24452.tar.xz ryzomcore_searx-1e9c7b9daac9bdee0822b66efdf607eed1e24452.zip |
Add example engine for use with khanindexer project
Diffstat (limited to '')
-rw-r--r-- | src/khanindexer.py | 47 | ||||
-rw-r--r-- | src/settings.yml | 4 |
2 files changed, 51 insertions, 0 deletions
diff --git a/src/khanindexer.py b/src/khanindexer.py new file mode 100644 index 0000000..dc020de --- /dev/null +++ b/src/khanindexer.py @@ -0,0 +1,47 @@ +# khanindexer +# +# @website https://git.khaganat.net/neodarz/khanindexer +# +# @results JSON +# @stable yes +# @parse (general) url, title, content + +from urllib import urlencode +import json + +# engine dependent config +categories = ['general'] # TODO , 'images', 'music', 'videos', 'files' +paging = False +language_support = False +number_of_results = 5 + +# search-url +base_url = 'http://127.0.0.1:5000' +search_url = '/?{query}' + + +# do search-request +def request(query, params): + + params['url'] = base_url +\ + search_url.format(query=urlencode({'search': query})) + + print(params['url']) + return params + + +# get response from search-request +def response(resp): + results = [] + + datas = json.loads(resp.text) + + for el in datas: + results.append({ + 'title': el['title'], + 'content': el['excerpts'][0], + 'url': el['url'] + }) + + # return results + return results diff --git a/src/settings.yml b/src/settings.yml index db1cf22..de6a2c4 100644 --- a/src/settings.yml +++ b/src/settings.yml @@ -69,6 +69,10 @@ engines: engine: RyzomForum shortcut: rc + - name: khanindexer + engine: khanindexer + shortcut: kh + locales: en : English |