|
@@ -0,0 +1,43 @@
|
|
1
|
+"""
|
|
2
|
+ Asksteem (general)
|
|
3
|
+
|
|
4
|
+ @website https://asksteem.com/
|
|
5
|
+ @provide-api yes
|
|
6
|
+
|
|
7
|
+ @using-api yes
|
|
8
|
+ @results JSON (https://github.com/Hoxly/asksteem-docs/wiki)
|
|
9
|
+ @stable yes
|
|
10
|
+ @parse url, title, content
|
|
11
|
+"""
|
|
12
|
+
|
|
13
|
+from json import loads
|
|
14
|
+from searx.url_utils import urlencode
|
|
15
|
+
|
|
16
|
+# engine dependent config
|
|
17
|
+categories = ['general']
|
|
18
|
+paging = True
|
|
19
|
+language_support = False
|
|
20
|
+disabled = True
|
|
21
|
+
|
|
22
|
+# search-url
|
|
23
|
+search_url = 'https://api.asksteem.com/search?{params}'
|
|
24
|
+result_url = 'https://steemit.com/@{author}/{title}'
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+# do search-request
|
|
28
|
+def request(query, params):
|
|
29
|
+ url = search_url.format(params=urlencode({'q': query, 'pg': params['pageno']}))
|
|
30
|
+ params['url'] = url
|
|
31
|
+ return params
|
|
32
|
+
|
|
33
|
+# get response from search-request
|
|
34
|
+def response(resp):
|
|
35
|
+ json = loads(resp.text)
|
|
36
|
+
|
|
37
|
+ results = []
|
|
38
|
+
|
|
39
|
+ for result in json.get('results', []):
|
|
40
|
+ results.append({'url': result_url.format(author=result['author'], title=result['permlink']),
|
|
41
|
+ 'title': result['title'],
|
|
42
|
+ 'content': result['summary']})
|
|
43
|
+ return results
|