blob: 9364bab41ee0ccaae340a52cde2df163cb5c8e09 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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
|