diff options
author | Cqoicebordel <Cqoicebordel@users.noreply.github.com> | 2015-02-09 16:55:01 +0100 |
---|---|---|
committer | Cqoicebordel <Cqoicebordel@users.noreply.github.com> | 2015-02-09 16:55:01 +0100 |
commit | 0a537d3b89964c227724d3cd95adebd2bbafb720 (patch) | |
tree | 37aef610898020583db60a491a90e208b8ce14e4 /searx/engines/yacy.py | |
parent | fb04f76698f8fd7347aa54a42e99ecb7ea5f7df0 (diff) | |
download | searxng-0a537d3b89964c227724d3cd95adebd2bbafb720.tar.gz searxng-0a537d3b89964c227724d3cd95adebd2bbafb720.zip |
Yacy's unit test
Diffstat (limited to 'searx/engines/yacy.py')
-rw-r--r-- | searx/engines/yacy.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/searx/engines/yacy.py b/searx/engines/yacy.py index 17e2a7aab..3d26c9cc4 100644 --- a/searx/engines/yacy.py +++ b/searx/engines/yacy.py @@ -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 |