diff options
| author | Adam Tauber <asciimoo@gmail.com> | 2020-03-13 00:50:19 +0100 |
|---|---|---|
| committer | Adam Tauber <asciimoo@gmail.com> | 2020-03-13 00:50:19 +0100 |
| commit | 018b6818419a1c3044b7d7244b55a62779063071 (patch) | |
| tree | 03b08a68bf52f603df75da2db7cb6e02e27ea882 | |
| parent | 9bc24080bf4c24a182cf2b5616095c2f6bea5821 (diff) | |
[fix] add answers, suggestions, corrections to csv output
fixes #1888
| -rw-r--r-- | searx/webapp.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/searx/webapp.py b/searx/webapp.py index da2bf34a9..49129d14e 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -626,10 +626,20 @@ def index(): mimetype='application/json') elif output_format == 'csv': csv = UnicodeWriter(StringIO()) - keys = ('title', 'url', 'content', 'host', 'engine', 'score') + keys = ('title', 'url', 'content', 'host', 'engine', 'score', 'type') csv.writerow(keys) for row in results: row['host'] = row['parsed_url'].netloc + row['type'] = 'result' + csv.writerow([row.get(key, '') for key in keys]) + for a in result_container.answers: + row = {'title': a, 'type': 'answer'} + csv.writerow([row.get(key, '') for key in keys]) + for a in result_container.suggestions: + row = {'title': a, 'type': 'suggestion'} + csv.writerow([row.get(key, '') for key in keys]) + for a in result_container.corrections: + row = {'title': a, 'type': 'correction'} csv.writerow([row.get(key, '') for key in keys]) csv.stream.seek(0) response = Response(csv.stream.read(), mimetype='application/csv') |