Skip to content

Instantly share code, notes, and snippets.

@LyndonArmitage
Created May 23, 2013 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LyndonArmitage/5638174 to your computer and use it in GitHub Desktop.
Save LyndonArmitage/5638174 to your computer and use it in GitHub Desktop.
This is a basic python script to check the average cert gained per minute on Planetside 2 using their API.
import requests
import time
__author__ = "Lyndon Armitage"
check_interval = 60 * 1 # Every 1 min
interval = 60 * 1 # Interval to sleep at (can be faster than check interval)
last_check_time = time.clock() - check_interval
username = "theanchorman"
start_certs = 0
certs = []
def get_certs():
name = username.lower()
r = requests.get("http://census.soe.com/get/ps2-beta/character/?name.first_lower=" + name + "&c:show=certs")
obj = r.json()
certs = obj["character_list"][0]["certs"]["currentpoints"]
return float(certs)
def get_average():
total = 0
for num in certs:
total += num - start_certs
average = total / len(certs)
return average
start_certs = get_certs()
while True:
now = time.clock()
if now - last_check_time >= check_interval:
certs.append(get_certs())
print time.strftime("%H:%M:%S", time.localtime()) + " - Average cert gain per minute: " + str(get_average())
last_check_time = time.clock()
time.sleep(interval)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment