Skip to content

Instantly share code, notes, and snippets.

@hzlzh
Created September 6, 2012 10:13
Show Gist options
  • Select an option

  • Save hzlzh/3654352 to your computer and use it in GitHub Desktop.

Select an option

Save hzlzh/3654352 to your computer and use it in GitHub Desktop.
load Diablo 3 info
import bottle
import os
import urllib2, json, contextlib
def application(environ, start_response):
data = load_info('hzlzh#1356','us')
start_response("200 OK", [
("Content-Type", "text/plain"),
("Content-Length", str(len(data)))
])
return iter([data])
def load_info(battleID, *region):
s = ''
for i in range(0, len(region)):
battleID = battleID.replace('#','-')
myProfile_temp = urllib2.urlopen('http://'+region[i]+'.battle.net/api/d3/profile/'+battleID+'/');
myProfile = myProfile_temp.read()
data1 = ''
myProfile_temp.close()
for data1 in json.loads(myProfile)['heroes']:
s += '\n---'+region[i]+'---'+\
'\nName:'+data1['name']+\
'\nLevel:'+str(data1['level'])+\
'\nCareer:'+data1['class']
return s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment