mirror of
https://github.com/searxng/searxng.git
synced 2024-11-19 02:40:11 +01:00
[fix] pep8
This commit is contained in:
parent
672f1c674c
commit
91f9973227
@ -28,15 +28,17 @@ search_url = base_url + 'w/api.php?action=query'\
|
|||||||
'&srprop=timestamp'\
|
'&srprop=timestamp'\
|
||||||
'&format=json'\
|
'&format=json'\
|
||||||
'&sroffset={offset}'\
|
'&sroffset={offset}'\
|
||||||
'&srlimit={limit}'
|
'&srlimit={limit}' # noqa
|
||||||
|
|
||||||
|
|
||||||
# do search-request
|
# do search-request
|
||||||
def request(query, params):
|
def request(query, params):
|
||||||
offset = (params['pageno'] - 1) * number_of_results
|
offset = (params['pageno'] - 1) * number_of_results
|
||||||
|
|
||||||
string_args = dict(query=urlencode({'srsearch': query}),
|
string_args = dict(query=urlencode({'srsearch': query}),
|
||||||
offset=offset,
|
offset=offset,
|
||||||
limit=number_of_results)
|
limit=number_of_results)
|
||||||
|
|
||||||
format_strings = list(Formatter().parse(base_url))
|
format_strings = list(Formatter().parse(base_url))
|
||||||
|
|
||||||
if params['language'] == 'all':
|
if params['language'] == 'all':
|
||||||
@ -67,7 +69,8 @@ def response(resp):
|
|||||||
|
|
||||||
# parse results
|
# parse results
|
||||||
for result in search_results['query']['search']:
|
for result in search_results['query']['search']:
|
||||||
url = base_url.format(language=resp.search_params['language']) + 'wiki/' + quote(result['title'].replace(' ', '_').encode('utf-8'))
|
url = base_url.format(language=resp.search_params['language']) +\
|
||||||
|
'wiki/' + quote(result['title'].replace(' ', '_').encode('utf-8'))
|
||||||
|
|
||||||
# append result
|
# append result
|
||||||
results.append({'url': url,
|
results.append({'url': url,
|
||||||
|
@ -24,7 +24,11 @@ number_of_results = 5
|
|||||||
|
|
||||||
# search-url
|
# search-url
|
||||||
base_url = 'http://localhost:8090'
|
base_url = 'http://localhost:8090'
|
||||||
search_url = '/yacysearch.json?{query}&startRecord={offset}&maximumRecords={limit}&contentdom={search_type}&resource=global'
|
search_url = '/yacysearch.json?{query}'\
|
||||||
|
'&startRecord={offset}'\
|
||||||
|
'&maximumRecords={limit}'\
|
||||||
|
'&contentdom={search_type}'\
|
||||||
|
'&resource=global' # noqa
|
||||||
|
|
||||||
# yacy specific type-definitions
|
# yacy specific type-definitions
|
||||||
search_types = {'general': 'text',
|
search_types = {'general': 'text',
|
||||||
@ -39,7 +43,8 @@ def request(query, params):
|
|||||||
offset = (params['pageno'] - 1) * number_of_results
|
offset = (params['pageno'] - 1) * number_of_results
|
||||||
search_type = search_types.get(params['category'], '0')
|
search_type = search_types.get(params['category'], '0')
|
||||||
|
|
||||||
params['url'] = base_url + search_url.format(query=urlencode({'query': query}),
|
params['url'] = base_url +\
|
||||||
|
search_url.format(query=urlencode({'query': query}),
|
||||||
offset=offset,
|
offset=offset,
|
||||||
limit=number_of_results,
|
limit=number_of_results,
|
||||||
search_type=search_type)
|
search_type=search_type)
|
||||||
|
Loading…
Reference in New Issue
Block a user