Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #!venv/bin/python
  2. import sys
  3.  
  4. import requests, json
  5. from prettytable import PrettyTable
  6. from requests import RequestException
  7. from requests.auth import HTTPBasicAuth
  8. import getpass
  9.  
  10. username = input("username: ")
  11. password = getpass.getpass("password: ")
  12.  
  13. try:
  14. r = requests.get('https://www.ag-bank.com/API/accounts.json', auth=HTTPBasicAuth(username, password))
  15. r.raise_for_status()
  16. except RequestException as e:
  17. print(e)
  18. sys.exit(0)
  19.  
  20. response = json.loads(r.text)
  21. table = PrettyTable(["retail","currency","balance_credit"])
  22. for i in response:
  23. table.add_row([
  24. i['retail'],
  25. i['currency'],
  26. i['balance']['credit'],
  27. ])
  28. print(table)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement