Reformat file
This commit is contained in:
parent
8abeaac017
commit
8ed7a39b86
48
sherlock.py
48
sherlock.py
|
|
@ -2,9 +2,10 @@ import requests
|
|||
import json
|
||||
import os
|
||||
|
||||
|
||||
def write_to_file(url, fname):
|
||||
with open(fname, "a") as f:
|
||||
f.write(url+"\n")
|
||||
with open(fname, "a") as f:
|
||||
f.write(url + "\n")
|
||||
|
||||
|
||||
def main():
|
||||
|
|
@ -22,14 +23,17 @@ def main():
|
|||
username = input("\033[92;1m[\033[37;1m?\033[92;1m]\033[92;1m Input Username: \033[0m")
|
||||
print()
|
||||
|
||||
fname = username+".txt"
|
||||
fname = username + ".txt"
|
||||
|
||||
if os.path.isfile(fname):
|
||||
os.remove(fname)
|
||||
print("\033[1;92m[\033[0m\033[1;77m*\033[0m\033[1;92m] Removing previous file:\033[1;37m {}\033[0m".format(fname))
|
||||
os.remove(fname)
|
||||
print(
|
||||
"\033[1;92m[\033[0m\033[1;77m*\033[0m\033[1;92m] Removing previous file:\033[1;37m {}\033[0m".format(fname))
|
||||
|
||||
|
||||
print("\033[1;92m[\033[0m\033[1;77m*\033[0m\033[1;92m] Checking username\033[0m\033[1;37m {}\033[0m\033[1;92m on: \033[0m".format(username))
|
||||
print(
|
||||
"\033[1;92m[\033[0m\033[1;77m*\033[0m\033[1;92m] Checking username\033[0m\033[1;37m {}\033[0m\033[1;92m on: "
|
||||
"\033[0m".format(
|
||||
username))
|
||||
raw = open("data.json", "r")
|
||||
data = json.load(raw)
|
||||
|
||||
|
|
@ -43,38 +47,38 @@ def main():
|
|||
for social_network in data:
|
||||
url = data.get(social_network).get("url").format(username)
|
||||
error_type = data.get(social_network).get("errorType")
|
||||
|
||||
|
||||
r = requests.get(url, headers=headers)
|
||||
|
||||
|
||||
if error_type == "message":
|
||||
error = data.get(social_network).get("errorMsg")
|
||||
|
||||
|
||||
if not error in r.text:
|
||||
print("\033[37;1m[\033[92;1m+\033[37;1m]\033[92;1m {}:\033[0m".format(social_network), url)
|
||||
write_to_file(url, fname)
|
||||
|
||||
write_to_file(url, fname)
|
||||
|
||||
else:
|
||||
print("\033[37;1m[\033[91;1m-\033[37;1m]\033[92;1m {}:\033[93;1m Not Found!".format(social_network))
|
||||
|
||||
print("\033[37;1m[\033[91;1m-\033[37;1m]\033[92;1m {}:\033[93;1m Not Found!".format(social_network))
|
||||
|
||||
elif error_type == "status_code":
|
||||
|
||||
|
||||
if not r.status_code == 404:
|
||||
print("\033[37;1m[\033[92;1m+\033[37;1m]\033[92;1m {}:\033[0m".format(social_network), url)
|
||||
write_to_file(url, fname)
|
||||
|
||||
|
||||
else:
|
||||
print("\033[37;1m[\033[91;1m-\033[37;1m]\033[92;1m {}:\033[93;1m Not Found!".format(social_network))
|
||||
print("\033[37;1m[\033[91;1m-\033[37;1m]\033[92;1m {}:\033[93;1m Not Found!".format(social_network))
|
||||
|
||||
elif error_type == "response_url":
|
||||
error = data.get(social_network).get("errorMsgInUrl")
|
||||
|
||||
|
||||
if not error in r.url:
|
||||
print("\033[37;1m[\033[92;1m+\033[37;1m]\033[92;1m {}:\033[0m".format(social_network), url)
|
||||
write_to_file(url, fname)
|
||||
else:
|
||||
print("\033[37;1m[\033[91;1m-\033[37;1m]\033[92;1m {}:\033[93;1m Not Found!".format(social_network))
|
||||
print("\033[37;1m[\033[91;1m-\033[37;1m]\033[92;1m {}:\033[93;1m Not Found!".format(social_network))
|
||||
|
||||
print("\033[1;92m[\033[0m\033[1;77m*\033[0m\033[1;92m] Saved: \033[37;1m{}\033[0m".format(username+".txt"))
|
||||
|
||||
main()
|
||||
print("\033[1;92m[\033[0m\033[1;77m*\033[0m\033[1;92m] Saved: \033[37;1m{}\033[0m".format(username + ".txt"))
|
||||
|
||||
|
||||
main()
|
||||
|
|
|
|||
Loading…
Reference in New Issue