logo

searx

Unnamed repository; edit this file 'description' to name the repository.
commit: ba131c842d70440d240105de4ddcbe710ad9c894
parent: 3c8a5f2cd31ea78b1e416e09e6ce1ac80403965e
Author: asciimoo <asciimoo@gmail.com>
Date:   Mon,  2 Dec 2013 21:36:09 +0100

[enh][fix] csv output updates

Diffstat:

searx/webapp.py | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/searx/webapp.py b/searx/webapp.py @@ -113,14 +113,15 @@ def index(): return Response(json.dumps({'query': query, 'results': results}), mimetype='application/json') elif request_data.get('format') == 'csv': csv = UnicodeWriter(cStringIO.StringIO()) + keys = ('title', 'url', 'content', 'host', 'engine', 'score') if len(results): - keys = results[0].keys() csv.writerow(keys) for row in results: - csv.writerow([row[key] for key in keys]) + row['host'] = row['parsed_url'].netloc + csv.writerow([row.get(key, '') for key in keys]) csv.stream.seek(0) response = Response(csv.stream.read(), mimetype='application/csv') - response.headers.add('Content-Disposition', 'attachment;Filename=searx_-_{0}.csv'.format(query)) + response.headers.add('Content-Disposition', 'attachment;Filename=searx_-_{0}.csv'.format('_'.join(query.split()))) return response template = render('results.html'