215febri

sendgrid

Mar 25th, 2021
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # requirement: requests, json, argparse
  3.  
  4. import requests
  5. import json
  6. import argparse
  7.  
  8. logsukses = "success.txt"
  9. logfail = "failed.txt"
  10.  
  11. def SngApi(sengridapi):
  12. sukses = open(logsukses, "a")
  13. gagal = open(logfail, "a")
  14.  
  15. try:
  16. headers = {
  17. 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0',
  18. 'Authorization': 'Bearer '+sengridapi,
  19. }
  20. SengtidGetLimit = requests.get('https://api.sendgrid.com/v3/user/credits',headers=headers)
  21. Limit = json.loads(SengtidGetLimit.text)["total"]
  22. Used = json.loads(SengtidGetLimit.text)["used"]
  23. SendgridMf = requests.get('https://api.sendgrid.com/v3/user/email',headers=headers)
  24. Mf = json.loads(SendgridMf.text)['email']
  25. print('user : apikey')
  26. print('limit :', Limit)
  27. print('used :', Used)
  28. print('Mail from :', Mf)
  29. sukses.write('user : apikey'"\n"'stripkey : '+sengridapi+"\nStatus : %s\n" % Limit)
  30. sukses.write("used : %s\n" % Used)
  31. sukses.write("mailfrom : %s\n" % Mf)
  32. sukses.write("---------------------------------------------------------------------------\n")
  33. except:
  34. print("ERROR: Get data failed")
  35. gagal.write(sengridapi+" -> Failed Get Data\n")
  36.  
  37. print('''
  38.  
  39. ____ _____ _ _ ____ ____ ____ ___ ____
  40. / ___|| ____| \ | | _ \ / ___| _ \|_ _| _ \
  41. \___ \| _| | \| | | | | | _| |_) || || | | |
  42. ___) | |___| |\ | |_| | |_| | _ < | || |_| |
  43. |____/|_____|_| \_|____/ \____|_| \_\___|____/
  44.  
  45.  
  46. BRIBIN KIRIK
  47. ''')
  48.  
  49. fname = input('Input your file: ')
  50. file = open(fname)
  51. nx = file.readlines()
  52. for xid in nx:
  53. try:
  54. xid = xid.rstrip('\n')
  55. sengridapi = xid
  56. print('#################################')
  57. print('Sendgrid Apikey :', sengridapi)
  58. SngApi(sengridapi)
  59. except:
  60. print('ERROR: Parsing failed')
  61. print('#################################')
Advertisement
Add Comment
Please, Sign In to add comment