forked from Icycoide/searxng
[fix] pep/flake8 compatibility
This commit is contained in:
parent
692c0bf5f0
commit
b2492c94f4
23 changed files with 197 additions and 109 deletions
|
@ -3,10 +3,12 @@ from urllib import urlencode, quote
|
|||
|
||||
url = 'https://en.wikipedia.org/'
|
||||
|
||||
search_url = url + 'w/api.php?action=query&list=search&{query}&srprop=timestamp&format=json' # noqa
|
||||
|
||||
number_of_results = 10
|
||||
|
||||
|
||||
def request(query, params):
|
||||
search_url = url + 'w/api.php?action=query&list=search&{query}&srprop=timestamp&format=json'
|
||||
params['url'] = search_url.format(query=urlencode({'srsearch': query}))
|
||||
return params
|
||||
|
||||
|
@ -14,7 +16,5 @@ def request(query, params):
|
|||
def response(resp):
|
||||
search_results = loads(resp.text)
|
||||
res = search_results.get('query', {}).get('search', [])
|
||||
|
||||
return [{'url': url + 'wiki/' + quote(result['title'].replace(' ', '_').encode('utf-8')),
|
||||
return [{'url': url + 'wiki/' + quote(result['title'].replace(' ', '_').encode('utf-8')), # noqa
|
||||
'title': result['title']} for result in res[:int(number_of_results)]]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue