logo

searx

My custom branche(s) on searx, a meta-search engine git clone https://hacktivis.me/git/searx.git

asksteem.py (1059B)


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