summaryrefslogtreecommitdiff
path: root/searx/engines/asksteem.py
blob: 6738780fa911ab1e3b2eb4876add32dac2e767dc (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
43
44
"""
 Asksteem (general)

 @website     https://asksteem.com/
 @provide-api yes

 @using-api   yes
 @results     JSON (https://github.com/Hoxly/asksteem-docs/wiki)
 @stable      yes
 @parse       url, title, content
"""

from json import loads
from searx.url_utils import urlencode

# engine dependent config
categories = ['general']
paging = True
language_support = False
disabled = True

# search-url
search_url = 'https://api.asksteem.com/search?{params}'
result_url = 'https://steemit.com/@{author}/{title}'


# do search-request
def request(query, params):
    url = search_url.format(params=urlencode({'q': query, 'pg': params['pageno']}))
    params['url'] = url
    return params


# get response from search-request
def response(resp):
    json = loads(resp.text)

    results = []

    for result in json.get('results', []):
        results.append({'url': result_url.format(author=result['author'], title=result['permlink']),
                        'title': result['title'],
                        'content': result['summary']})
    return results