mirror of
https://github.com/searxng/searxng.git
synced 2025-08-02 18:12:21 +02:00
Yacy's unit test
This commit is contained in:
parent
fb04f76698
commit
0a537d3b89
3 changed files with 109 additions and 9 deletions
|
@ -25,10 +25,10 @@ number_of_results = 5
|
|||
# search-url
|
||||
base_url = 'http://localhost:8090'
|
||||
search_url = '/yacysearch.json?{query}'\
|
||||
'&startRecord={offset}'\
|
||||
'&maximumRecords={limit}'\
|
||||
'&contentdom={search_type}'\
|
||||
'&resource=global' # noqa
|
||||
'&startRecord={offset}'\
|
||||
'&maximumRecords={limit}'\
|
||||
'&contentdom={search_type}'\
|
||||
'&resource=global'
|
||||
|
||||
# yacy specific type-definitions
|
||||
search_types = {'general': 'text',
|
||||
|
@ -41,7 +41,7 @@ search_types = {'general': 'text',
|
|||
# do search-request
|
||||
def request(query, params):
|
||||
offset = (params['pageno'] - 1) * number_of_results
|
||||
search_type = search_types.get(params['category'], '0')
|
||||
search_type = search_types.get(params.get('category'), '0')
|
||||
|
||||
params['url'] = base_url +\
|
||||
search_url.format(query=urlencode({'query': query}),
|
||||
|
@ -66,9 +66,12 @@ def response(resp):
|
|||
if not raw_search_results:
|
||||
return []
|
||||
|
||||
search_results = raw_search_results.get('channels', {})[0].get('items', [])
|
||||
search_results = raw_search_results.get('channels', [])
|
||||
|
||||
for result in search_results:
|
||||
if len(search_results) == 0:
|
||||
return []
|
||||
|
||||
for result in search_results[0].get('items', []):
|
||||
# parse image results
|
||||
if result.get('image'):
|
||||
# append result
|
||||
|
@ -88,7 +91,7 @@ def response(resp):
|
|||
'content': result['description'],
|
||||
'publishedDate': publishedDate})
|
||||
|
||||
#TODO parse video, audio and file results
|
||||
# TODO parse video, audio and file results
|
||||
|
||||
# return results
|
||||
return results
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue