summaryrefslogtreecommitdiff
path: root/searx/engines/qwant_social.py
diff options
context:
space:
mode:
authorCqoicebordel <Cqoicebordel@users.noreply.github.com>2015-06-02 20:36:58 +0200
committerCqoicebordel <Cqoicebordel@users.noreply.github.com>2015-06-02 20:36:58 +0200
commitf05087b93ac1ebef3bdacd353524bac0d8041832 (patch)
tree41d3d6901cc969f216c485811b7f19baf62212ff /searx/engines/qwant_social.py
parent884eeb8541e0a4cf3d65c2a17e1c2f788cab7fb1 (diff)
Refactor
Use only one engine for the four search from Qwant
Diffstat (limited to 'searx/engines/qwant_social.py')
-rw-r--r--searx/engines/qwant_social.py69
1 files changed, 0 insertions, 69 deletions
diff --git a/searx/engines/qwant_social.py b/searx/engines/qwant_social.py
deleted file mode 100644
index 474dfac02..000000000
--- a/searx/engines/qwant_social.py
+++ /dev/null
@@ -1,69 +0,0 @@
-"""
- Qwant (social media)
-
- @website https://qwant.com/
- @provide-api not officially (https://api.qwant.com/api/search/)
-
- @using-api yes
- @results JSON
- @stable yes
- @parse url, title, content
-"""
-
-from urllib import urlencode
-from json import loads
-from datetime import datetime
-
-# engine dependent config
-categories = ['social media']
-paging = True
-language_support = True
-
-# search-url
-url = 'https://api.qwant.com/api/search/social?count=10&offset={offset}&f=&{query}'
-
-
-# do search-request
-def request(query, params):
- offset = (params['pageno'] - 1) * 10
-
- params['url'] = url.format(query=urlencode({'q': query}),
- offset=offset)
-
- # add language tag if specified
- if params['language'] != 'all':
- params['url'] += '&locale=' + params['language'].lower()
-
- return params
-
-
-# get response from search-request
-def response(resp):
- results = []
-
- search_results = loads(resp.text)
-
- # return empty array if there are no results
- if 'data' not in search_results:
- return []
-
- data = search_results.get('data', {})
-
- res = data.get('result', {})
-
- # parse results
- for result in res.get('items', {}):
-
- title = result['title']
- res_url = result['url']
- content = result['desc']
- published_date = datetime.fromtimestamp(result['date'], None)
-
- # append result
- results.append({'url': res_url,
- 'title': title,
- 'content': content,
- 'publishedDate': published_date})
-
- # return results
- return results