Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # requirement: requests, json, argparse
- import requests
- import json
- import argparse
- logsukses = "success.txt"
- logfail = "failed.txt"
- def SngApi(sengridapi):
- sukses = open(logsukses, "a")
- gagal = open(logfail, "a")
- try:
- headers = {
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0',
- 'Authorization': 'Bearer '+sengridapi,
- }
- SengtidGetLimit = requests.get('https://api.sendgrid.com/v3/user/credits',headers=headers)
- Limit = json.loads(SengtidGetLimit.text)["total"]
- Used = json.loads(SengtidGetLimit.text)["used"]
- SendgridMf = requests.get('https://api.sendgrid.com/v3/user/email',headers=headers)
- Mf = json.loads(SendgridMf.text)['email']
- print('user : apikey')
- print('limit :', Limit)
- print('used :', Used)
- print('Mail from :', Mf)
- sukses.write('user : apikey'"\n"'stripkey : '+sengridapi+"\nStatus : %s\n" % Limit)
- sukses.write("used : %s\n" % Used)
- sukses.write("mailfrom : %s\n" % Mf)
- sukses.write("---------------------------------------------------------------------------\n")
- except:
- print("ERROR: Get data failed")
- gagal.write(sengridapi+" -> Failed Get Data\n")
- print('''
- ____ _____ _ _ ____ ____ ____ ___ ____
- / ___|| ____| \ | | _ \ / ___| _ \|_ _| _ \
- \___ \| _| | \| | | | | | _| |_) || || | | |
- ___) | |___| |\ | |_| | |_| | _ < | || |_| |
- |____/|_____|_| \_|____/ \____|_| \_\___|____/
- BRIBIN KIRIK
- ''')
- fname = input('Input your file: ')
- file = open(fname)
- nx = file.readlines()
- for xid in nx:
- try:
- xid = xid.rstrip('\n')
- sengridapi = xid
- print('#################################')
- print('Sendgrid Apikey :', sengridapi)
- SngApi(sengridapi)
- except:
- print('ERROR: Parsing failed')
- print('#################################')
Advertisement
Add Comment
Please, Sign In to add comment