Explorar el Código

Merge f34733c3fe78ff61bbe7ef46e9ca1b64d7ff99da into f82ead3e303d75ba63a370dc038311e172e1330d

Nícholas Kegler hace 6 años
padre
commit
c2309286d4
Ninguna cuenta está vinculada al correo electrónico del colaborador
Se han modificado 2 ficheros con 50 adiciones y 0 borrados
  1. 45
    0
      searx/engines/opensemantic.py
  2. 5
    0
      searx/settings.yml

+ 45
- 0
searx/engines/opensemantic.py Ver fichero

@@ -0,0 +1,45 @@
1
+"""
2
+Open Semantic Search
3
+
4
+ @website    https://www.opensemanticsearch.org/
5
+ @provide-api yes (https://www.opensemanticsearch.org/dev)
6
+
7
+ @using-api  yes
8
+ @results    JSON
9
+ @stable     yes
10
+ @parse      url, title, content, publishedDate
11
+"""
12
+from dateutil import parser
13
+from json import loads
14
+from searx.url_utils import quote
15
+
16
+base_url = 'http://localhost:8983/solr/opensemanticsearch/'
17
+search_string = 'query?q={query}'
18
+
19
+
20
+def request(query, params):
21
+    search_path = search_string.format(
22
+        query=quote(query),
23
+    )
24
+    params['url'] = base_url + search_path
25
+    return params
26
+
27
+
28
+def response(resp):
29
+    results = []
30
+    data = loads(resp.text)
31
+    docs = data.get('response', {}).get('docs', [])
32
+
33
+    for current in docs:
34
+        item = {}
35
+        item['url'] = current['id']
36
+        item['title'] = current['title_txt_txt_en']
37
+        if current.get('content_txt'):
38
+            item['content'] = current['content_txt'][0]
39
+        item['publishedDate'] = parser.parse(
40
+            current['file_modified_dt']
41
+        )
42
+        item['originalData'] = current
43
+        results.append(item)
44
+
45
+    return results

+ 5
- 0
searx/settings.yml Ver fichero

@@ -464,6 +464,11 @@ engines:
464 464
     shortcut : oap
465 465
     timeout: 5.0
466 466
 
467
+  - name : opensemanticsearch
468
+    engine : opensemantic
469
+    shortcut : oss
470
+    base_url : 'http://localhost:8983/solr/opensemanticsearch/'
471
+
467 472
   - name : openstreetmap
468 473
     engine : openstreetmap
469 474
     shortcut : osm