Script to get world of warcraft data and display it in a website.
In [27]:
import battlenet
import dominate
from dominate.tags import *
import json
import arrow
import requests
In [28]:
import datetime
In [29]:
from battlenet import Character
In [30]:
from battlenet import Realm
In [14]:
#Realm.to_json()
In [15]:
realm = Realm(battlenet.UNITED_STATES, "jubei'thos")
In [16]:
realm
Out[16]:
In [17]:
print realm.is_online()
In [18]:
print realm.to_json()
In [19]:
rejs = json.loads(realm.to_json())
In [20]:
rejs
Out[20]:
In [21]:
rtza = rejs['timezone']
In [23]:
arrow.get('US/Pacific')
In [24]:
arrow.get(rtza)
In [25]:
realm.slug
Out[25]:
In [26]:
realm.population
Out[26]:
In [27]:
realm.type
Out[27]:
In [28]:
realm.status
Out[28]:
In [29]:
relmjs = realm.to_json['timezone']
In [30]:
#charget = battlenet.
inpd character name input ut realm an.
In [32]:
lookuprealm = raw_input("Enter US realm name: ")
lookupchar = raw_input("Enter character: ")
In [33]:
bookchar = Character(battlenet.UNITED_STATES, lookuprealm, lookupchar)
In [34]:
bospnam = bookchar.get_spec_name
In [35]:
bookchar.achievement_points
Out[35]:
In [38]:
bokjs = bookchar.to_json()
In [39]:
import json
In [41]:
bokjsz = json.loads(bokjs)
In [ ]:
In [44]:
bokjst = bokjsz['stats']
In [48]:
bokza = bokjst.keys()
In [ ]:
In [51]:
for bok in bokza:
print bok
print bokjst[bok]
In [ ]:
In [ ]:
If faction is alliance change CSS to BLUE background. If faction is horde change css to RED background.
This script displays a wow character given by input of character name and realm name.
In [54]:
if bookchar.faction == 'Alliance':
print ('Alliance has a blue background')
else:
print ('Horde has a red background')
In [54]:
In [55]:
bookchar.to_json()
Out[55]:
In [56]:
opcharjs = open('/home/wcmckee/github/garrison-wow-track/charstats.json')
In [1]:
opcharjs.read()
In [57]:
In [57]:
In [57]:
In [57]:
In [57]:
In [57]:
In [57]:
In [57]:
In [58]:
bookchar.get_thumbnail_url()
Out[58]:
In [59]:
bookdatz = bookchar.last_modified.date()
In [60]:
bookchar.last_modified.year
Out[60]:
In [61]:
bookdatz.month
Out[61]:
In [62]:
bookdatz.min
Out[62]:
In [63]:
bookchar.last_modified.microsecond
Out[63]:
In [64]:
bookchar.gender
Out[64]:
In [65]:
battlenet.things.Reputation()
In [66]:
geninfo = dict()
In [67]:
if bookchar.gender == 1:
geninfo.update({'gender': 'female'})
In [68]:
if bookchar.gender == 0:
geninfo.update({'gender': 'male'})
In [69]:
geninfo
Out[69]:
In [70]:
for bocha in bookchar.professions['primary']:
print bocha.recipes
In [71]:
profz = bocha.recipes
In [72]:
import requests
In [73]:
recreqs = requests.get('http://us.battle.net/api/wow/recipe/33994')
In [74]:
recreqs
Out[74]:
In [75]:
requests.get('http://google.com')
Out[75]:
In [76]:
battlenet.q
In [76]:
In [76]:
In [77]:
bookchar.last_modified.day
Out[77]:
In [78]:
bookchar.last_modified.weekday()
Out[78]:
In [79]:
bookchar.last_modified.hour
Out[79]:
In [80]:
racnum = bookchar.race
In [81]:
battlenet.RACE
Out[81]:
In [82]:
print battlenet.RACE[racnum]
In [83]:
battlenet.RACE_TO_FACTION
Out[83]:
In [84]:
print battlenet.RACE_TO_FACTION[racnum]
In [85]:
print battlenet.quote
In [86]:
print battlenet.enums.CLASS
In [87]:
print bookchar.class_
In [88]:
print battlenet.enums.CLASS[racnum]
In [88]:
In [89]:
bokkall = bookchar.to_json()
In [90]:
bokkall
Out[90]:
In [91]:
json.loads(bokkall)['lastModified']
Out[91]:
In [91]:
In [92]:
import json
In [93]:
json.loads
Out[93]:
In [94]:
json.loads(bokkall)['items']
In [95]:
for bequ in bookchar.equipment:
print bequ
In [ ]:
from battlenet import Connection
In [96]:
for realm in connection.get_all_realms(battlenet.UNITED_STATES):
print realm
#for realm in connection.get_all_realms(battlenet.UNITED_STATES):
# print realm
In [97]:
from battlenet import Guild
# If a global connection was setup
guild = Guild(battlenet.UNITED_STATES, "jubei'thos", "adventure time")
In [98]:
glead = guild.get_leader
In [99]:
guildjson = guild.to_json()
In [100]:
glead()
In [ ]:
guild.realm
In [101]:
battlenet.connection.Connection.get_character_races
Out[101]:
In [102]:
item = battlenet.connection.Connection.get_all_realms
# TODO
In [103]:
name = "Kiljaeden"
realm = battlenet.
In [104]:
portchar = Character(battlenet.UNITED_STATES, "saurfang", "portishead")
In [105]:
portchar.to_json()
Out[105]:
In [106]:
portchar.level
Out[106]:
In [107]:
portmoded = portchar.last_modified
In [108]:
portmoded.year
Out[108]:
In [109]:
portmoded.month
Out[109]:
In [110]:
portmoded.day
Out[110]:
In [111]:
portapc = portchar.appearance
In [112]:
portapc.face
Out[112]:
In [113]:
portapc.skin_color
Out[113]:
In [114]:
portapc.feature
Out[114]:
In [115]:
portapc.hair
Out[115]:
In [116]:
portchar.get_class_name()
Out[116]:
In [117]:
portchar.get_race_name()
Out[117]:
In [118]:
portprof = portchar.professions['primary']
In [119]:
for ppof in portprof:
#print ppof.recipes
for pprec in ppof.recipes:
print pprec
In [120]:
portales = portchar.TALENTS
In [121]:
portreq = portchar.equipment
In [122]:
portreq.average_item_level
Out[122]:
In [123]:
portreq.average_item_level_equiped
Out[123]:
In [124]:
realm.to_json()
Out[124]:
In [125]:
bnetthing = battlenet.things
In [126]:
battlenet.RACE_TO_FACTION
Out[126]:
In [127]:
alrac = battlenet.RACE
In [128]:
import random
In [129]:
random.choice(alrac.values())
Out[129]:
In [130]:
plaqual = battlenet.QUALITY
In [131]:
random.choice(plaqual.values())
Out[131]:
In [132]:
battlenet.Character
Out[132]:
In [133]:
battlenet.connection()
In [133]:
In [134]:
alclas = battlenet.CLASS
In [135]:
alclas
Out[135]:
In [136]:
random.choice(alclas.values())
Out[136]:
In [137]:
battlenet.things
Out[137]:
In [137]:
In [138]:
portales
Out[138]:
In [138]:
Make background red if horde - blue if alliance.
Depend on class.
In [139]:
portchar.faction
Out[139]:
In [140]:
portchar.
In [141]:
portchat
In [142]:
galfchar = Character(battlenet.UNITED_STATES, "jubei'thos", 'galf')
In [143]:
galfchar
Out[143]:
In [144]:
galfchar.to_json()
Out[144]:
In [145]:
gquiq = galfchar.equipment
In [146]:
gquiq.average_item_level
Out[146]:
In [147]:
gquiq.average_item_level_equiped
Out[147]:
In [148]:
gdarz = galfchar.get_spec_name
In [149]:
gdarz()
In [ ]:
import random
In [150]:
gfinz = galfchar.titles
In [151]:
diczid = list()
In [152]:
for gfin in gfinz:
print gfin
diczid.append(gfin)
In [153]:
len(diczid)
Out[153]:
In [154]:
rantitle = random.choice(diczid)
In [155]:
print rantitle
In [166]:
if (' ') in str(rantitle):
print ('space!')
str.replace(str(rantitle), ' ', '_')
In [172]:
fixstrz = str.replace(str(rantitle), ' ', '_')
In [171]:
str(rantitle)
Out[171]:
In [173]:
fixstrz
Out[173]:
In [ ]:
In [156]:
gquiq.hands.name
Out[156]:
In [157]:
gquiq.to_json()
Out[157]:
In [160]:
doc = dominate.document(title='garrisonwowtrack')
with doc.head:
link(rel='stylesheet', href='style.css')
script(type ='text/javascript', src='script.js')
#str(str2)
with div():
attr(cls='header')
h1(str(rantitle))
p(img('/imgs/getsdrawn-bw.png', src='/imgs/getsdrawn-bw.png'))
#p(img('imgs/15/01/02/ReptileLover82-reference.png', src= 'imgs/15/01/02/ReptileLover82-reference.png'))
#h1('Updated ', str(artes.datetime))
#p(panz)
#p(bodycom)
for bok in bokza:
p(bok)
p(bokjst[bok])
'''
with doc:
with div(id='body').add(ol()):
for flc in fulcom:
if 'http://i.imgur.com' in flc.url:
p(h1(flc.title))
p(img(imlocdir, src= imlocdir))
#p(img(flc.url, src = flc.url))
p(str(flc.author))
#res = requests.get(flc.url, stream=True)
#with open(str(flc.author) + '-' + str(artes.date()) + '-reference.png', 'wb') as outfil:
# shutil.copyfileobj(res.raw, outfil)
# del res
for flcz in flc.comments:
p(flcz.body)
#for rdz in reliz:
#h1(rdz.title)
#a(rdz.url)
#p(img(rdz, src='%s' % rdz))
#print rdz
#p(img(rdz, src = rdz))
#p(rdz)
#print rdz.url
#if '.jpg' in rdz.url:
# img(rdz.urlz)
#else:
# a(rdz.urlz)
#h1(str(rdz.author))
#li(img(i.lower(), src='%s' % i))
with div():
attr(cls='body')
p('GotDrawn is open source')
a('https://github.com/getsdrawn/getsdrawndotcom')
a('https://reddit.com/r/redditgetsdrawn')
'''
print doc
In [4]:
reqallre = requests.get('http://us.battle.net/api/wow/realm/status')
In [7]:
reqtxt = reqallre.text
In [10]:
jsre = json.loads(reqtxt)
In [15]:
lerez = len(jsre['realms'])
In [16]:
lerez
Out[16]:
In [33]:
for jsrez in jsre['realms']:
print jsrez['name']
#realm = Realm(battlenet.UNITED_STATES, jsrez['name'])
#portchar = Character(battlenet.UNITED_STATES, jsrez['name'], "portishead")
In [ ]:
realm = Realm(battlenet.UNITED_STATES, jsrez['name')
In [19]:
#Return all realms.
In [ ]:
In [ ]: