Created
July 12, 2010 21:11
-
-
Save aragaer/473063 to your computer and use it in GitHub Desktop.
Python and EVE
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
#!/usr/bin/python | |
import urllib | |
import urllib2 | |
from xml.dom.minidom import parse | |
user_id = 2373898 | |
api_key = "<snip>" | |
char_id = 1580122797 | |
uri_base = 'http://api.eve-online.com' | |
api_pages = { | |
'char list': '/account/Characters.xml.aspx', | |
'acct cash': '/char/AccountBalance.xml.aspx', | |
} | |
def GetData(page, params): | |
uri = uri_base + api_pages[page] | |
doc = parse(urllib2.urlopen(uri, urllib.urlencode(params))) | |
attrs = doc.getElementsByTagName('rowset')[0].getAttribute('columns').split(',') | |
return [dict([(a, row.getAttribute(a)) for a in attrs]) \ | |
for row in doc.getElementsByTagName('row')] | |
def GetChars(): | |
return GetData('char list', {'userId': user_id, 'apiKey': api_key}) | |
def GetAccount(char = char_id): | |
return GetData('acct cash', | |
{'userId': user_id, | |
'apiKey': api_key, | |
'characterID': char}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment