mirror of https://github.com/searxng/searxng.git
parent
9bc24080bf
commit
018b681841
|
@ -626,10 +626,20 @@ def index():
|
||||||
mimetype='application/json')
|
mimetype='application/json')
|
||||||
elif output_format == 'csv':
|
elif output_format == 'csv':
|
||||||
csv = UnicodeWriter(StringIO())
|
csv = UnicodeWriter(StringIO())
|
||||||
keys = ('title', 'url', 'content', 'host', 'engine', 'score')
|
keys = ('title', 'url', 'content', 'host', 'engine', 'score', 'type')
|
||||||
csv.writerow(keys)
|
csv.writerow(keys)
|
||||||
for row in results:
|
for row in results:
|
||||||
row['host'] = row['parsed_url'].netloc
|
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.writerow([row.get(key, '') for key in keys])
|
||||||
csv.stream.seek(0)
|
csv.stream.seek(0)
|
||||||
response = Response(csv.stream.read(), mimetype='application/csv')
|
response = Response(csv.stream.read(), mimetype='application/csv')
|
||||||
|
|
Loading…
Reference in New Issue