From d9e600d05dccc3303311faf140bea4a692d99e3f Mon Sep 17 00:00:00 2001 From: "Christopher K. Hoadley" Date: Fri, 28 Dec 2018 22:32:30 -0600 Subject: [PATCH] Add support for writing to Comma-Separated Values (CSV) File with all of the results. Unfortunately, the request text is so long that it is not visible in spreadsheet programs. So, I am leaving this off for now. --- .gitignore | 3 +++ sherlock.py | 28 +++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5e38a44d..2e5e5bec 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ # Output files, except requirements.txt *.txt !requirements.txt + +# Comma-Separated Values (CSV) Reports +*.csv diff --git a/sherlock.py b/sherlock.py index d8d5acc9..d9549cfb 100644 --- a/sherlock.py +++ b/sherlock.py @@ -8,6 +8,7 @@ import json import os import sys import re +import csv from argparse import ArgumentParser, RawDescriptionHelpFormatter import platform @@ -192,6 +193,10 @@ def main(): action="store_false", dest="verbose", help="Disable debugging information (Default Option)." ) + parser.add_argument("--csv", + action="store_true", dest="csv", default=False, + help="Create Comma-Separated Values (CSV) File." + ) parser.add_argument("username", nargs='+', metavar='USERNAMES', action="store", @@ -217,5 +222,26 @@ def main(): print() results = sherlock(username, verbose=args.verbose) + if args.csv == True: + with open(username + ".csv", "w", newline='') as csv_report: + writer = csv.writer(csv_report) + writer.writerow(['username', + 'name', + 'url_main', + 'url_user', + 'exists', + 'http_status' + ] + ) + for site in results: + writer.writerow([username, + site, + results[site]['url_main'], + results[site]['url_user'], + results[site]['exists'], + results[site]['http_status'] + ] + ) + if __name__ == "__main__": - main() \ No newline at end of file + main()