summaryrefslogtreecommitdiff
path: root/searx/engines/opensemantic.py
diff options
context:
space:
mode:
authorNicholas Kegler <nicholasks@gmail.com>2018-06-14 15:32:20 -0300
committerNoémi Ványi <sitbackandwait@gmail.com>2020-10-25 17:50:00 +0100
commit8e15d3e4c1ed077a42d67fdad19fa6ab00f91261 (patch)
tree36ceec1ae269363d2adff5a03a808001071b9511 /searx/engines/opensemantic.py
parentaa3c18dda9329fff875328f6ba97483c417b149a (diff)
downloadsearxng-8e15d3e4c1ed077a42d67fdad19fa6ab00f91261.tar.gz
searxng-8e15d3e4c1ed077a42d67fdad19fa6ab00f91261.zip
Open Semantic Search Engine
Diffstat (limited to 'searx/engines/opensemantic.py')
-rw-r--r--searx/engines/opensemantic.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/searx/engines/opensemantic.py b/searx/engines/opensemantic.py
new file mode 100644
index 000000000..9364bab41
--- /dev/null
+++ b/searx/engines/opensemantic.py
@@ -0,0 +1,42 @@
+"""
+Open Semantic Search
+
+ @website https://www.opensemanticsearch.org/
+ @provide-api yes (https://www.opensemanticsearch.org/dev)
+
+ @using-api yes
+ @results JSON
+ @stable yes
+ @parse url, title, content, publishedDate
+"""
+from dateutil import parser
+from json import loads
+from urllib.parse import quote
+
+base_url = 'http://localhost:8983/solr/opensemanticsearch/'
+search_string = 'query?q={query}'
+
+
+def request(query, params):
+ search_path = search_string.format(
+ query=quote(query),
+ )
+ params['url'] = base_url + search_path
+ return params
+
+
+def response(resp):
+ results = []
+ data = loads(resp.text)
+ docs = data.get('response', {}).get('docs', [])
+
+ for current in docs:
+ item = {}
+ item['url'] = current['id']
+ item['title'] = current['title_txt_txt_en']
+ if current.get('content_txt'):
+ item['content'] = current['content_txt'][0]
+ item['publishedDate'] = parser.parse(current['file_modified_dt'])
+ results.append(item)
+
+ return results