Skip to content

Instantly share code, notes, and snippets.

@aragaer
Created July 12, 2010 21:11
Show Gist options
  • Save aragaer/473063 to your computer and use it in GitHub Desktop.
Save aragaer/473063 to your computer and use it in GitHub Desktop.
Python and EVE
#!/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