Skip to content

Commit

Permalink
Update emails.py
Browse files Browse the repository at this point in the history
Fix HIBP
  • Loading branch information
woj-ciech authored Sep 27, 2018
1 parent 80da9dd commit 4f7cfa8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,23 @@ def haveibeenpwned(self):
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36"}
req_haveibeenpwned = requests.get("https://haveibeenpwned.com/api/v2/breachedaccount/" + self.email_address,
headers=user_agent)
if req_haveibeenpwned != 200:
print "Connection error"
if req_haveibeenpwned.status_code != 200:
if req_haveibeenpwned.status_code == 404:
print "account not pwned"
return False
print "Connection error " + str(req_haveibeenpwned.status_code) + " " + req_haveibeenpwned.text
return False

json_haveibeenpwned = json.loads(req_haveibeenpwned.content)
domains = []
for i in json_haveibeenpwned:
domains.append(i['Domain'])

if len(domains) > 0:
for i in domains:
print i
else:
print "No results"
print bcolors.OKGREEN + i + bcolors.ENDC
else:
print "No results"

return domains

Expand Down

0 comments on commit 4f7cfa8

Please sign in to comment.