Skip to content

Incredibly fast crawler designed for OSINT.

Initial support for exporting to CSV (fixes #89)

Fabian Affolter561b3c6cbace
diff --git a/plugins/exporter.py b/plugins/exporter.py
index c42a883..207cc67 100644
--- a/plugins/exporter.py
+++ b/plugins/exporter.py
@@ -1,12 +1,24 @@
"""Support for exporting the results."""
+import csv
import json
def exporter(directory, method, datasets):
- """Export the results."""
- if method.lower() == 'json':
- # Convert json_dict to a JSON styled string
- json_string = json.dumps(datasets, indent=4)
- savefile = open('%s/exported.json' % directory, 'w+')
- savefile.write(json_string)
- savefile.close()
+ """Export the results."""
+ if method.lower() == 'json':
+ # Convert json_dict to a JSON styled string
+ json_string = json.dumps(datasets, indent=4)
+ savefile = open('{}/exported.json'.format(directory), 'w+')
+ savefile.write(json_string)
+ savefile.close()
+
+ if method.lower() == 'csv':
+ with open('{}/exported.csv'.format(directory), 'w+') as csvfile:
+ csv_writer = csv.writer(
+ csvfile, delimiter=',', quoting=csv.QUOTE_MINIMAL)
+ for key, values in datasets.items():
+ if values is None:
+ csv_writer.writerow([key])
+ else:
+ csv_writer.writerow([key] + values)
+ csvfile.close()