Commit 1e9c7b9d authored by neodarz's avatar neodarz

Add example engine for use with khanindexer project

parent fe8b741f
Pipeline #635 failed with stages
......@@ -10,6 +10,7 @@ ln -s ../../../src/khaganatForum.py searx/searx/engines/khaganatForum.py
ln -s ../../../src/forgeryzom.py searx/searx/engines/forgeryzom.py
ln -s ../../../src/ryzomcoreConfluence.py searx/searx/engines/ryzomcoreConfluence.py
ln -s ../../../src/RyzomForum.py searx/searx/engines/RyzomForum.py
ln -s ../../../src/khanindexer.py searx/searx/engines/khanindexer.py
cp src/settings.yml searx/searx/settings.yml
virtualenv venv -p python2.7
source venv/bin/activate
......
# 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
......@@ -69,6 +69,10 @@ engines:
engine: RyzomForum
shortcut: rc
- name: khanindexer
engine: khanindexer
shortcut: kh
locales:
en : English
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment