Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion sherlock_project/sherlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,30 @@ def main():
)

if args.output:
result_file = args.output
if os.path.exists(args.output): # Check if given filepath exists.
if os.path.isdir(args.output): # Filename exists and is a directory.
result_file = os.path.join(args.output, f"{username}")
else:
result_file = args.output # Filename already exists and is overwritten.
else:
parent_dir = os.path.dirname(args.output.rstrip("/"))
if args.output.endswith(os.sep):
os.makedirs(args.output, exist_ok=True)
result_file = os.path.join(args.output, f"{username}")
else:
if parent_dir:
os.makedirs(parent_dir, exist_ok=True)
result_file = args.output

with open(result_file, "w", encoding="utf-8") as file:
exists_counter = 0
for website_name in results:
dictionary = results[website_name]
if dictionary.get("status").status == QueryStatus.CLAIMED:
exists_counter += 1
file.write(dictionary["url_user"] + "\n")
file.write(f"Total Websites Username Detected On : {exists_counter}\n")

elif args.folderoutput:
# The usernames results should be stored in a targeted folder.
# If the folder doesn't exist, create it first
Expand Down