Created
May 10, 2023 19:13
-
-
Save robbmanes/f1d04c0e946de7fb7ede35377394e743 to your computer and use it in GitHub Desktop.
Get HLL CRCON VIP ID's and export them to CSV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import requests | |
import sys | |
RCON_URL='http://mycoolrcon.example' | |
RCON_USERNAME='admin' | |
RCON_PASSWORD='password' | |
CSV_FILE='vips.csv' | |
def main(): | |
session = requests.session() | |
response = session.get(RCON_URL + '/api/login', json={'username': RCON_USERNAME, 'password': RCON_PASSWORD}) | |
data = response.json() | |
if data['failed']: | |
print('Failure logging in!') | |
print(data) | |
return | |
response = session.get(RCON_URL + '/api/get_vip_ids') | |
data = response.json() | |
if data['failed']: | |
print('Failed to get VIP ID\'s!') | |
print(data) | |
return | |
with open(CSV_FILE, 'a', newline='') as f: | |
writer = csv.writer(f, dialect='excel') | |
writer.writerow(['steam_id_64', 'name', 'vip_expiration']) | |
for entry in data['result']: | |
print(entry) | |
writer.writerow([entry['steam_id_64'], entry['name'], entry['vip_expiration']]) | |
if __name__ == '__main__': | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment