Advertisement
byoussef

Code

Feb 23rd, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. Coding Assessment
  2. Branden Youssef
  3.  
  4. Enter an email address, get list of websites + where the user has possibly compromised accounts
  5. Using http://docs.python-requests.org/en/latest/ and https://docs.python.org/3/library/urllib.parse.html
  6. Python 3 code:
  7.  
  8.  
  9. import sys, requests, urllib
  10. print("__name__ value: ", __name__)
  11. def main():
  12.     email = sys.stdin.readline()
  13.     """ the url encoding below could alternatively be implemented
  14.     with a for loop and if else statements when encountering any
  15.     of the 8 characters that need to be encoded """
  16.     req = requests.get('https://haveibeenpwned.com/api/v2/breachedaccount/' + urllib.parse.urlencode(email) )
  17.     sys.stdout.write(req.headers['Domain'] )
  18.  
  19. if __name__ == '__main__':
  20.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement