SHARE
TWEET

Untitled

a guest Jan 12th, 2017 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from sys import argv
  2. from time import sleep
  3. import requests
  4.  
  5. if len(argv) != 3:
  6.     print(argv[0] + " emails.txt output_folder")
  7.  
  8. with open(argv[1], "r") as f:
  9.     for email in f:
  10.         email = email.strip()
  11.         while True:
  12.             url = "https://haveibeenpwned.com/api/v2/breachedaccount/" + email
  13.             r = requests.get(url)
  14.  
  15.             if r.status_code == 429:
  16.                 if "Retry-After" in r.headers:
  17.                     sleep(int(r.headers["Retry-After"]))
  18.                 else:
  19.                     sleep(5)
  20.             elif r.status_code == 404:
  21.                 print(email + " not pwned")
  22.                 break
  23.             elif r.status_code == 200:
  24.                 print(email + " pwned")
  25.                 with open(argv[2] + "/" + email, "w") as o:
  26.                     o.write(r.text)
  27.  
  28.                 break
  29.             else:
  30.                 print(email + " failed")
  31.                 break
RAW Paste Data
Top