|
|
@ -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,10 +43,11 @@ 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 +\
|
|
|
|
offset=offset,
|
|
|
|
search_url.format(query=urlencode({'query': query}),
|
|
|
|
limit=number_of_results,
|
|
|
|
offset=offset,
|
|
|
|
search_type=search_type)
|
|
|
|
limit=number_of_results,
|
|
|
|
|
|
|
|
search_type=search_type)
|
|
|
|
|
|
|
|
|
|
|
|
# add language tag if specified
|
|
|
|
# add language tag if specified
|
|
|
|
if params['language'] != 'all':
|
|
|
|
if params['language'] != 'all':
|
|
|
@ -70,19 +75,19 @@ def response(resp):
|
|
|
|
|
|
|
|
|
|
|
|
# append result
|
|
|
|
# append result
|
|
|
|
results.append({'url': result['link'],
|
|
|
|
results.append({'url': result['link'],
|
|
|
|
'title': result['title'],
|
|
|
|
'title': result['title'],
|
|
|
|
'content': result['description'],
|
|
|
|
'content': result['description'],
|
|
|
|
'publishedDate': publishedDate})
|
|
|
|
'publishedDate': publishedDate})
|
|
|
|
|
|
|
|
|
|
|
|
elif resp.search_params['category'] == 'images':
|
|
|
|
elif resp.search_params['category'] == 'images':
|
|
|
|
# parse image results
|
|
|
|
# parse image results
|
|
|
|
for result in search_results:
|
|
|
|
for result in search_results:
|
|
|
|
# append result
|
|
|
|
# append result
|
|
|
|
results.append({'url': result['url'],
|
|
|
|
results.append({'url': result['url'],
|
|
|
|
'title': result['title'],
|
|
|
|
'title': result['title'],
|
|
|
|
'content': '',
|
|
|
|
'content': '',
|
|
|
|
'img_src': result['image'],
|
|
|
|
'img_src': result['image'],
|
|
|
|
'template': 'images.html'})
|
|
|
|
'template': 'images.html'})
|
|
|
|
|
|
|
|
|
|
|
|
#TODO parse video, audio and file results
|
|
|
|
#TODO parse video, audio and file results
|
|
|
|
|
|
|
|
|
|
|
|