GarrissonWow

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]:
<Realm: Jubei'Thos(US)>

In [17]:
print realm.is_online()


True

In [18]:
print realm.to_json()


{"status": true, "wintergrasp": {"status": 0, "next": 1435814838442, "controlling-faction": 0, "area": 1}, "battlegroup": "AU/NZ Battle Group", "name": "Jubei'Thos", "tol-barad": {"status": 0, "next": 1435813897791, "controlling-faction": 1, "area": 21}, "locale": "en_US", "queue": false, "connected_realms": ["gundrak", "jubeithos", "internal-record-3697"], "timezone": "Australia/Melbourne", "type": "pvp", "slug": "jubeithos", "population": "low"}

In [19]:
rejs = json.loads(realm.to_json())

In [20]:
rejs


Out[20]:
{u'battlegroup': u'AU/NZ Battle Group',
 u'connected_realms': [u'gundrak', u'jubeithos', u'internal-record-3697'],
 u'locale': u'en_US',
 u'name': u"Jubei'Thos",
 u'population': u'low',
 u'queue': False,
 u'slug': u'jubeithos',
 u'status': True,
 u'timezone': u'Australia/Melbourne',
 u'tol-barad': {u'area': 21,
  u'controlling-faction': 1,
  u'next': 1435813897791L,
  u'status': 0},
 u'type': u'pvp',
 u'wintergrasp': {u'area': 1,
  u'controlling-faction': 0,
  u'next': 1435814838442L,
  u'status': 0}}

In [21]:
rtza = rejs['timezone']

In [23]:
arrow.get('US/Pacific')


---------------------------------------------------------------------------
ParserError                               Traceback (most recent call last)
<ipython-input-23-c1d111b94fc4> in <module>()
----> 1 arrow.get('US/Pacific')

/usr/local/lib/python2.7/dist-packages/arrow/api.pyc in get(*args, **kwargs)
     21     '''
     22 
---> 23     return _factory.get(*args, **kwargs)
     24 
     25 def utcnow():

/usr/local/lib/python2.7/dist-packages/arrow/factory.pyc in get(self, *args, **kwargs)
    161             # (str) -> now, @ tzinfo.
    162             elif isstr(arg):
--> 163                 dt = parser.DateTimeParser(locale).parse_iso(arg)
    164                 return self.type.fromdatetime(dt)
    165 

/usr/local/lib/python2.7/dist-packages/arrow/parser.pyc in parse_iso(self, string)
     98             formats = [item.replace('T', ' ', 1) for item in formats]
     99 
--> 100         return self._parse_multiformat(string, formats)
    101 
    102     def parse(self, string, fmt):

/usr/local/lib/python2.7/dist-packages/arrow/parser.pyc in _parse_multiformat(self, string, formats)
    240 
    241         if _datetime is None:
--> 242             raise ParserError('Could not match input to any of {0} on \'{1}\''.format(formats, string))
    243 
    244         return _datetime

ParserError: Could not match input to any of ['YYYY-MM-DD', 'YYYY-MM', 'YYYY'] on 'US/Pacific'

In [24]:
arrow.get(rtza)


---------------------------------------------------------------------------
ParserError                               Traceback (most recent call last)
<ipython-input-24-dae548da2386> in <module>()
----> 1 arrow.get(rtza)

/usr/local/lib/python2.7/dist-packages/arrow/api.pyc in get(*args, **kwargs)
     21     '''
     22 
---> 23     return _factory.get(*args, **kwargs)
     24 
     25 def utcnow():

/usr/local/lib/python2.7/dist-packages/arrow/factory.pyc in get(self, *args, **kwargs)
    161             # (str) -> now, @ tzinfo.
    162             elif isstr(arg):
--> 163                 dt = parser.DateTimeParser(locale).parse_iso(arg)
    164                 return self.type.fromdatetime(dt)
    165 

/usr/local/lib/python2.7/dist-packages/arrow/parser.pyc in parse_iso(self, string)
     98             formats = [item.replace('T', ' ', 1) for item in formats]
     99 
--> 100         return self._parse_multiformat(string, formats)
    101 
    102     def parse(self, string, fmt):

/usr/local/lib/python2.7/dist-packages/arrow/parser.pyc in _parse_multiformat(self, string, formats)
    240 
    241         if _datetime is None:
--> 242             raise ParserError('Could not match input to any of {0} on \'{1}\''.format(formats, string))
    243 
    244         return _datetime

ParserError: Could not match input to any of ['YYYY-MM-DD', 'YYYY-MM', 'YYYY'] on 'Australia/Melbourne'

In [25]:
realm.slug


Out[25]:
'jubeithos'

In [26]:
realm.population


Out[26]:
'low'

In [27]:
realm.type


Out[27]:
'pvp'

In [28]:
realm.status


Out[28]:
True

In [29]:
relmjs = realm.to_json['timezone']


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-29-f19f8060be5d> in <module>()
----> 1 relmjs = realm.to_json['timezone']

TypeError: 'instancemethod' object has no attribute '__getitem__'

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: ")


Enter US realm name: saurfang
Enter character: portishead

In [33]:
bookchar = Character(battlenet.UNITED_STATES, lookuprealm, lookupchar)

In [34]:
bospnam = bookchar.get_spec_name

In [35]:
bookchar.achievement_points


Out[35]:
8175

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]


bonusArmor
109
critRating
855
powerType
runic-power
multistrikeRating
14.121212
mainHandDps
2041.5823
int
572
leechRatingBonus
0.0
spr
640
spellCritRating
855
avoidanceRating
0.0
spellPower
572
rangedDps
-1.0
leechRating
0.0
crit
12.772727
mastery
26.436363
multistrike
14.121212
versatilityDamageDoneBonus
2.184615
armor
2297
avoidanceRatingBonus
0.0
spellCrit
12.772727
mana5Combat
0.0
mana5
0.0
health
238740
rangedDmgMax
-1.0
rangedDmgMin
-1.0
hasteRatingPercent
7.777778
leech
0.0
versatilityDamageTakenBonus
1.092308
dodge
5.0
power
105
spellPen
0
mainHandSpeed
3.006
attackPower
3480
speedRating
0.0
multistrikeRatingBonus
4.121212
hasteRating
700
masteryRating
574
blockRating
0
parry
16.6417
versatility
284
parryRating
855
dodgeRating
0
sta
3979
mainHandDmgMin
5654.0
speedRatingBonus
0.0
mainHandDmgMax
6620.0
agi
1073
offHandDps
699.99756
rangedSpeed
-1.0
versatilityHealingDoneBonus
2.184615
offHandDmgMax
1169.0
haste
19.74112
rangedAttackPower
0
str
2965
offHandDmgMin
1168.0
block
0.0
offHandSpeed
1.67

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')


Alliance has a blue background

In [54]:


In [55]:
bookchar.to_json()


Out[55]:
'{"stats": {"bonusArmor": 109, "critRating": 855, "powerType": "runic-power", "spellCrit": 12.772727, "mainHandDps": 2041.5823, "int": 572, "leechRatingBonus": 0.0, "spr": 640, "mainHandDmgMax": 6620.0, "spellCritRating": 855, "avoidanceRating": 0.0, "spellPower": 572, "mainHandDmgMin": 5654.0, "leechRating": 0.0, "crit": 12.772727, "multistrike": 14.121212, "versatilityDamageDoneBonus": 2.184615, "rangedSpeed": -1.0, "armor": 2297, "avoidanceRatingBonus": 0.0, "multistrikeRating": 14.121212, "mana5Combat": 0.0, "mana5": 0.0, "health": 238740, "rangedDmgMax": -1.0, "rangedDmgMin": -1.0, "hasteRatingPercent": 7.777778, "leech": 0.0, "rangedAttackPower": 0, "dodge": 5.0, "power": 105, "spellPen": 0, "attackPower": 3480, "mainHandSpeed": 3.006, "speedRating": 0.0, "multistrikeRatingBonus": 4.121212, "masteryRating": 574, "blockRating": 0, "parry": 16.6417, "versatility": 284, "parryRating": 855, "dodgeRating": 0, "sta": 3979, "agi": 1073, "speedRatingBonus": 0.0, "mastery": 26.436363, "rangedDps": -1.0, "offHandDps": 699.99756, "versatilityDamageTakenBonus": 1.092308, "versatilityHealingDoneBonus": 2.184615, "offHandDmgMax": 1169.0, "haste": 19.74112, "hasteRating": 700, "str": 2965, "offHandDmgMin": 1168.0, "block": 0.0, "offHandSpeed": 1.67}, "realm": "Saurfang", "name": "Portishead", "level": 100, "lastModified": 1435795373000, "totalHonorableKills": 1198, "thumbnail": "internal-record-3695/237/158282221-avatar.jpg", "race": 7, "calcClass": "d", "achievementPoints": 8175, "gender": 1, "battlegroup": "AU/NZ Battle Group", "class": 6}'

In [56]:
opcharjs = open('/home/wcmckee/github/garrison-wow-track/charstats.json')

In [1]:
opcharjs.read()


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-3830781d2421> in <module>()
----> 1 opcharjs.read()['stats']

NameError: name 'opcharjs' is not defined

In [57]:


In [57]:


In [57]:


In [57]:


In [57]:


In [57]:


In [57]:


In [57]:


In [58]:
bookchar.get_thumbnail_url()


Out[58]:
'http://us.battle.net/static-render/us/internal-record-3695/237/158282221-avatar.jpg'

In [59]:
bookdatz = bookchar.last_modified.date()

In [60]:
bookchar.last_modified.year


Out[60]:
2015

In [61]:
bookdatz.month


Out[61]:
7

In [62]:
bookdatz.min


Out[62]:
datetime.date(1, 1, 1)

In [63]:
bookchar.last_modified.microsecond


Out[63]:
0

In [64]:
bookchar.gender


Out[64]:
1

In [65]:
battlenet.things.Reputation()


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-65-e4b6fb86644a> in <module>()
----> 1 battlenet.things.Reputation()

TypeError: __init__() takes exactly 2 arguments (1 given)

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]:
{'gender': 'female'}

In [70]:
for bocha in bookchar.professions['primary']:
    print bocha.recipes


[7418, 7421, 7428, 158907, 158908, 158909, 158910, 158911, 159236, 162948, 169091, 169092, 177043]
[2660, 2663, 3115, 12260, 171690, 171691, 171692, 171693, 176090]

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]:
<Response [200]>

In [75]:
requests.get('http://google.com')


Out[75]:
<Response [200]>

In [76]:
battlenet.q


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-76-a9a04ea4a931> in <module>()
----> 1 battlenet.q

AttributeError: 'module' object has no attribute 'q'

In [76]:


In [76]:


In [77]:
bookchar.last_modified.day


Out[77]:
2

In [78]:
bookchar.last_modified.weekday()


Out[78]:
3

In [79]:
bookchar.last_modified.hour


Out[79]:
12

In [80]:
racnum = bookchar.race

In [81]:
battlenet.RACE


Out[81]:
{1: 'Human',
 2: 'Orc',
 3: 'Dwarf',
 4: 'Night Elf',
 5: 'Undead',
 6: 'Tauren',
 7: 'Gnome',
 8: 'Troll',
 9: 'Goblin',
 10: 'Blood Elf',
 11: 'Draenei',
 22: 'Worgen'}

In [82]:
print battlenet.RACE[racnum]


Gnome

In [83]:
battlenet.RACE_TO_FACTION


Out[83]:
{1: 'Alliance',
 2: 'Horde',
 3: 'Alliance',
 4: 'Alliance',
 5: 'Horde',
 6: 'Horde',
 7: 'Alliance',
 8: 'Horde',
 9: 'Horde',
 10: 'Horde',
 11: 'Alliance',
 22: 'Alliance'}

In [84]:
print battlenet.RACE_TO_FACTION[racnum]


Alliance

In [85]:
print battlenet.quote


<function quote at 0xb2333cb0>

In [86]:
print battlenet.enums.CLASS


{1: 'Warrior', 2: 'Paladin', 3: 'Hunter', 4: 'Rogue', 5: 'Priest', 6: 'Death Knight', 7: 'Shaman', 8: 'Mage', 9: 'Warlock', 11: 'Druid'}

In [87]:
print bookchar.class_


6

In [88]:
print battlenet.enums.CLASS[racnum]


Shaman

In [88]:


In [89]:
bokkall = bookchar.to_json()

In [90]:
bokkall


Out[90]:
'{"stats": {"bonusArmor": 109, "critRating": 855, "powerType": "runic-power", "spellCrit": 12.772727, "mainHandDps": 2041.5823, "int": 572, "leechRatingBonus": 0.0, "spr": 640, "mainHandDmgMax": 6620.0, "spellCritRating": 855, "avoidanceRating": 0.0, "spellPower": 572, "mainHandDmgMin": 5654.0, "leechRating": 0.0, "crit": 12.772727, "multistrike": 14.121212, "versatilityDamageDoneBonus": 2.184615, "rangedSpeed": -1.0, "armor": 2297, "avoidanceRatingBonus": 0.0, "multistrikeRating": 14.121212, "mana5Combat": 0.0, "mana5": 0.0, "health": 238740, "rangedDmgMax": -1.0, "rangedDmgMin": -1.0, "hasteRatingPercent": 7.777778, "leech": 0.0, "rangedAttackPower": 0, "dodge": 5.0, "power": 105, "spellPen": 0, "attackPower": 3480, "mainHandSpeed": 3.006, "speedRating": 0.0, "multistrikeRatingBonus": 4.121212, "masteryRating": 574, "blockRating": 0, "parry": 16.6417, "versatility": 284, "parryRating": 855, "dodgeRating": 0, "sta": 3979, "agi": 1073, "speedRatingBonus": 0.0, "mastery": 26.436363, "rangedDps": -1.0, "offHandDps": 699.99756, "versatilityDamageTakenBonus": 1.092308, "versatilityHealingDoneBonus": 2.184615, "offHandDmgMax": 1169.0, "haste": 19.74112, "hasteRating": 700, "str": 2965, "offHandDmgMin": 1168.0, "block": 0.0, "offHandSpeed": 1.67}, "realm": "Saurfang", "name": "Portishead", "level": 100, "lastModified": 1435795373000, "professions": {"primary": [{"name": "Enchanting", "max": 675, "recipes": [7418, 7421, 7428, 158907, 158908, 158909, 158910, 158911, 159236, 162948, 169091, 169092, 177043], "rank": 177, "id": 333, "icon": "trade_engraving"}, {"name": "Blacksmithing", "max": 675, "recipes": [2660, 2663, 3115, 12260, 171690, 171691, 171692, 171693, 176090], "rank": 101, "id": 164, "icon": "trade_blacksmithing"}], "secondary": [{"name": "First Aid", "max": 675, "recipes": [3275, 3276, 3277, 3278, 7928, 7929, 7934, 10840, 10841, 18629, 18630, 172539, 172540, 172541, 172542], "rank": 284, "id": 129, "icon": "spell_holy_sealofsacrifice"}, {"name": "Archaeology", "max": 75, "recipes": [], "rank": 1, "id": 794, "icon": "trade_archaeology"}, {"name": "Fishing", "max": 0, "recipes": [], "rank": 0, "id": 356, "icon": "trade_fishing"}, {"name": "Cooking", "max": 675, "recipes": [2538, 2540, 8604, 161001, 161002], "rank": 1, "id": 185, "icon": "inv_misc_food_15"}]}, "totalHonorableKills": 1198, "thumbnail": "internal-record-3695/237/158282221-avatar.jpg", "race": 7, "calcClass": "d", "achievementPoints": 8175, "gender": 1, "battlegroup": "AU/NZ Battle Group", "class": 6}'

In [91]:
json.loads(bokkall)['lastModified']


Out[91]:
1435795373000L

In [91]:


In [92]:
import json

In [93]:
json.loads


Out[93]:
<function json.loads>

In [94]:
json.loads(bokkall)['items']


---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-94-34f240b39924> in <module>()
----> 1 json.loads(bokkall)['items']

KeyError: 'items'

In [95]:
for bequ in bookchar.equipment:
    print bequ


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-95-3a1f1f50dcff> in <module>()
----> 1 for bequ in bookchar.equipment:
      2     print bequ

/usr/local/lib/python2.7/dist-packages/battlenet/things.pyc in __getitem__(self, item)
    477     def __getitem__(self, item):
    478         try:
--> 479             return getattr(self, item)
    480         except AttributeError:
    481             raise IndexError

TypeError: getattr(): attribute name must be string

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


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-96-5406d04091f1> in <module>()
----> 1 for realm in connection.get_all_realms(battlenet.UNITED_STATES):
      2 
      3     print realm
      4 #for realm in connection.get_all_realms(battlenet.UNITED_STATES):
      5 #    print realm

NameError: name 'connection' is not defined

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()


---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-100-ac0cc7ca42d1> in <module>()
----> 1 glead()

/usr/local/lib/python2.7/dist-packages/battlenet/things.pyc in get_leader(self)
    675 
    676     def get_leader(self):
--> 677         for member in self.members:
    678             if member['rank'] is 0:
    679                 return member['character']

/usr/local/lib/python2.7/dist-packages/battlenet/things.pyc in members(self)
    657 
    658             for member in self._data[Guild.MEMBERS]:
--> 659                 character = Character(self.region, data=member['character'], connection=self.connection)
    660                 character._guild = self
    661 

/usr/local/lib/python2.7/dist-packages/battlenet/things.pyc in __init__(self, region, realm, name, data, fields, connection)
    132             data = self.connection.get_character(region, realm, name, raw=True, fields=self._fields)
    133 
--> 134         self._populate_data(data)
    135 
    136     def __str__(self):

/usr/local/lib/python2.7/dist-packages/battlenet/things.pyc in _populate_data(self, data)
    158         self.gender = data['gender']
    159         self.achievement_points = data['achievementPoints']
--> 160         self.faction = RACE_TO_FACTION[self.race]
    161 
    162         if Character.GUILD in self._fields and Character.GUILD not in self._data:

KeyError: 26

In [ ]:
guild.realm

In [101]:
battlenet.connection.Connection.get_character_races


Out[101]:
<unbound method Connection.get_character_races>

In [102]:
item = battlenet.connection.Connection.get_all_realms
# TODO

In [103]:
name = "Kiljaeden"
realm = battlenet.


  File "<ipython-input-103-0f334316606a>", line 2
    realm = battlenet.
                      ^
SyntaxError: invalid syntax

In [104]:
portchar = Character(battlenet.UNITED_STATES, "saurfang", "portishead")

In [105]:
portchar.to_json()


Out[105]:
'{"realm": "Saurfang", "name": "Portishead", "level": 100, "lastModified": 1435795373000, "totalHonorableKills": 1198, "thumbnail": "internal-record-3695/237/158282221-avatar.jpg", "race": 7, "calcClass": "d", "achievementPoints": 8175, "gender": 1, "battlegroup": "AU/NZ Battle Group", "class": 6}'

In [106]:
portchar.level


Out[106]:
100

In [107]:
portmoded = portchar.last_modified

In [108]:
portmoded.year


Out[108]:
2015

In [109]:
portmoded.month


Out[109]:
7

In [110]:
portmoded.day


Out[110]:
2

In [111]:
portapc = portchar.appearance

In [112]:
portapc.face


Out[112]:
3

In [113]:
portapc.skin_color


Out[113]:
9

In [114]:
portapc.feature


Out[114]:
4

In [115]:
portapc.hair


Out[115]:
2

In [116]:
portchar.get_class_name()


Out[116]:
'Death Knight'

In [117]:
portchar.get_race_name()


Out[117]:
'Gnome'

In [118]:
portprof = portchar.professions['primary']

In [119]:
for ppof in portprof:
    #print ppof.recipes
    for pprec in ppof.recipes:
        print pprec


7418
7421
7428
158907
158908
158909
158910
158911
159236
162948
169091
169092
177043
2660
2663
3115
12260
171690
171691
171692
171693
176090

In [120]:
portales = portchar.TALENTS

In [121]:
portreq = portchar.equipment

In [122]:
portreq.average_item_level


Out[122]:
610

In [123]:
portreq.average_item_level_equiped


Out[123]:
607

In [124]:
realm.to_json()


Out[124]:
'{"status": true, "wintergrasp": {"status": 0, "next": 1435814838442, "controlling-faction": 0, "area": 1}, "battlegroup": "AU/NZ Battle Group", "name": "Jubei\'Thos", "tol-barad": {"status": 0, "next": 1435813897791, "controlling-faction": 1, "area": 21}, "locale": "en_US", "queue": false, "connected_realms": ["gundrak", "jubeithos", "internal-record-3697"], "timezone": "Australia/Melbourne", "type": "pvp", "slug": "jubeithos", "population": "low"}'

In [125]:
bnetthing = battlenet.things

In [126]:
battlenet.RACE_TO_FACTION


Out[126]:
{1: 'Alliance',
 2: 'Horde',
 3: 'Alliance',
 4: 'Alliance',
 5: 'Horde',
 6: 'Horde',
 7: 'Alliance',
 8: 'Horde',
 9: 'Horde',
 10: 'Horde',
 11: 'Alliance',
 22: 'Alliance'}

In [127]:
alrac = battlenet.RACE

In [128]:
import random

In [129]:
random.choice(alrac.values())


Out[129]:
'Orc'

In [130]:
plaqual = battlenet.QUALITY

In [131]:
random.choice(plaqual.values())


Out[131]:
'Epic'

In [132]:
battlenet.Character


Out[132]:
battlenet.things.Character

In [133]:
battlenet.connection()


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-133-816caf443389> in <module>()
----> 1 battlenet.connection()

TypeError: 'module' object is not callable

In [133]:


In [134]:
alclas = battlenet.CLASS

In [135]:
alclas


Out[135]:
{1: 'Warrior',
 2: 'Paladin',
 3: 'Hunter',
 4: 'Rogue',
 5: 'Priest',
 6: 'Death Knight',
 7: 'Shaman',
 8: 'Mage',
 9: 'Warlock',
 11: 'Druid'}

In [136]:
random.choice(alclas.values())


Out[136]:
'Paladin'

In [137]:
battlenet.things


Out[137]:
<module 'battlenet.things' from '/usr/local/lib/python2.7/dist-packages/battlenet/things.pyc'>

In [137]:


In [138]:
portales


Out[138]:
'talents'

In [138]:

Make background red if horde - blue if alliance.

Depend on class.


In [139]:
portchar.faction


Out[139]:
'Alliance'

In [140]:
portchar.


  File "<ipython-input-140-855652df3ce9>", line 1
    portchar.
             ^
SyntaxError: invalid syntax

In [141]:
portchat


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-141-176c844bb9da> in <module>()
----> 1 portchat

NameError: name 'portchat' is not defined

In [142]:
galfchar = Character(battlenet.UNITED_STATES, "jubei'thos", 'galf')

In [143]:
galfchar


Out[143]:
<Character: Galf@Jubei'Thos>

In [144]:
galfchar.to_json()


Out[144]:
'{"realm": "Jubei\'Thos", "name": "Galf", "level": 100, "lastModified": 1435794703000, "totalHonorableKills": 20336, "thumbnail": "internal-record-3697/221/155983837-avatar.jpg", "race": 10, "calcClass": "b", "achievementPoints": 8600, "gender": 1, "battlegroup": "AU/NZ Battle Group", "class": 2}'

In [145]:
gquiq = galfchar.equipment

In [146]:
gquiq.average_item_level


Out[146]:
607

In [147]:
gquiq.average_item_level_equiped


Out[147]:
607

In [148]:
gdarz = galfchar.get_spec_name

In [149]:
gdarz()


---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-149-ac998ca8aad0> in <module>()
----> 1 gdarz()

/usr/local/lib/python2.7/dist-packages/battlenet/things.pyc in get_spec_name(self)
    280 
    281     def get_spec_name(self):
--> 282         for talent in self.talents:
    283             if talent.selected:
    284                 return talent.name

/usr/local/lib/python2.7/dist-packages/battlenet/things.pyc in talents(self)
    253     def talents(self):
    254         if self._refresh_if_not_present(Character.TALENTS):
--> 255             self._talents = [Build(self, build) for build in self._data[Character.TALENTS]]
    256 
    257         return self._talents

/usr/local/lib/python2.7/dist-packages/battlenet/things.pyc in __init__(self, character, data)
    487         self._data = data
    488 
--> 489         self.build = data['build']
    490         self.icon = data.get('icon')
    491         self.name = data['name']

KeyError: 'build'

In [ ]:
import random

In [150]:
gfinz = galfchar.titles

In [151]:
diczid = list()

In [152]:
for gfin in gfinz:
    print gfin
    diczid.append(gfin)


Elder Galf
Flame Keeper Galf
Galf the Explorer
Galf the Hallowed
Galf, Champion of the Frozen Wastes
Ambassador Galf
Brewmaster Galf
Merrymaker Galf
Galf the Love Fool
Matron Galf
Galf Jenkins
Bloodsail Admiral Galf
Galf of Orgrimmar
Galf of Sen'jin
Galf of Silvermoon
Galf of Thunder Bluff
Galf of the Undercity
Galf the Noble
Crusader Galf
Galf the Patient

In [153]:
len(diczid)


Out[153]:
20

In [154]:
rantitle = random.choice(diczid)

In [155]:
print rantitle


Crusader Galf

In [166]:
if (' ') in str(rantitle):
    print ('space!')
    str.replace(str(rantitle), ' ', '_')


space!

In [172]:
fixstrz = str.replace(str(rantitle), ' ', '_')

In [171]:
str(rantitle)


Out[171]:
'Crusader Galf'

In [173]:
fixstrz


Out[173]:
'Crusader_Galf'

In [ ]:


In [156]:
gquiq.hands.name


Out[156]:
'Incarnadine Gauntlets'

In [157]:
gquiq.to_json()


Out[157]:
'{"shoulder": {"stats": [{"stat": 59, "amount": 83}, {"stat": 32, "amount": 55}, {"stat": 74, "amount": 109}, {"stat": 7, "amount": 163}], "name": "Gutcrusher Shoulderplates", "tooltipParams": {"timewalkerLevel": 100}, "armor": 226, "itemLevel": 615, "bonusLists": [522], "context": "dungeon-normal", "quality": 3, "id": 109946, "icon": "inv_shoulder_plate_draenordungeon_c_01"}, "averageItemLevelEquipped": 607, "averageItemLevel": 607, "neck": {"stats": [{"stat": 49, "amount": 64}, {"stat": 4, "amount": 103}, {"stat": 36, "amount": 72}, {"stat": 7, "amount": 155}], "name": "Glowing Taladite Pendant of the Feverflare", "tooltipParams": {"enchant": 5293, "timewalkerLevel": 100}, "armor": 0, "itemLevel": 640, "bonusLists": [121, 525, 540], "context": "trade-skill", "quality": 4, "id": 115799, "icon": "inv_jewelcrafting_necklace1_red"}, "trinket1": {"stats": [{"stat": 63, "amount": 62}, {"stat": 6, "amount": 138}], "name": "Munificent Censer of Tranquility", "tooltipParams": {"timewalkerLevel": 100}, "armor": 0, "itemLevel": 615, "bonusLists": [40], "context": "dungeon-normal", "quality": 3, "id": 114429, "icon": "inv_misc_trinket6oih_lanternb3"}, "trinket2": {"stats": [{"stat": 5, "amount": 117}], "name": "Winged Hourglass", "tooltipParams": {"timewalkerLevel": 100}, "armor": 0, "itemLevel": 640, "bonusLists": [525, 530], "context": "trade-skill", "quality": 4, "id": 112317, "icon": "inv_inscription_trinket_healer"}, "finger2": {"stats": [{"stat": 49, "amount": 26}, {"stat": 4, "amount": 36}, {"stat": 36, "amount": 22}, {"stat": 7, "amount": 54}], "name": "Botani Tender\'s Seal", "tooltipParams": {"timewalkerLevel": 100}, "armor": 0, "itemLevel": 528, "bonusLists": [], "context": "quest-reward", "quality": 2, "id": 112859, "icon": "inv_ringwod_d4_4"}, "finger1": {"stats": [{"stat": 59, "amount": 44}, {"stat": 40, "amount": 44}, {"stat": 4, "amount": 66}, {"stat": 7, "amount": 99}], "name": "Talon Guard Bloodsworn Ring", "tooltipParams": {"timewalkerLevel": 100}, "armor": 0, "itemLevel": 592, "bonusLists": [], "context": "quest-reward", "quality": 3, "id": 118069, "icon": "inv_ringwod_d3_1"}, "head": {"stats": [{"stat": 4, "amount": 133}, {"stat": 32, "amount": 177}, {"stat": 7, "amount": 199}], "name": "Polished Helm of Valor", "tooltipParams": {"timewalkerLevel": 100}, "armor": 238, "itemLevel": 605, "bonusLists": [583], "context": "", "quality": 7, "id": 122245, "icon": "inv_helmet_02"}, "mainHand": {"stats": [{"stat": 49, "amount": 90}, {"stat": 32, "amount": 94}, {"stat": 4, "amount": 139}, {"stat": 7, "amount": 208}], "name": "Greataxe of Trials", "tooltipParams": {"timewalkerLevel": 100}, "armor": 0, "itemLevel": 610, "weaponInfo": {"dps": 249.44446, "damage": {"max": 1079, "exactMin": 718.0, "exactMax": 1078.0, "min": 718}, "weaponSpeed": 3.6}, "bonusLists": [], "context": "quest-reward", "quality": 3, "id": 119458, "icon": "inv_axe_2h_draenordungeon_c_01"}, "back": {"stats": [{"stat": 32, "amount": 50}, {"stat": 4, "amount": 75}, {"stat": 36, "amount": 50}, {"stat": 7, "amount": 112}], "name": "Worn Stoneskin Gargoyle Cape", "tooltipParams": {"timewalkerLevel": 100}, "armor": 37, "itemLevel": 605, "bonusLists": [583], "context": "vendor", "quality": 7, "id": 122260, "icon": "inv_misc_cape_19"}, "feet": {"stats": [{"stat": 59, "amount": 55}, {"stat": 74, "amount": 109}, {"stat": 36, "amount": 83}, {"stat": 7, "amount": 163}], "name": "Greaves of Grievous Storms of the Deft", "tooltipParams": {"timewalkerLevel": 100}, "armor": 207, "itemLevel": 615, "bonusLists": [149], "context": "dungeon-normal", "quality": 3, "id": 114382, "icon": "inv_boot_plate_draenordungeon_c_01"}, "chest": {"stats": [{"stat": 59, "amount": 101}, {"stat": 74, "amount": 145}, {"stat": 36, "amount": 90}, {"stat": 7, "amount": 218}], "name": "Breastplate of Grievous Storms of the Deft", "tooltipParams": {"timewalkerLevel": 100}, "armor": 301, "itemLevel": 615, "bonusLists": [136], "context": "dungeon-normal", "quality": 3, "id": 114377, "icon": "inv_chest_plate_draenordungeon_c_01"}, "wrist": {"stats": [{"stat": 59, "amount": 57}, {"stat": 32, "amount": 76}, {"stat": 74, "amount": 103}, {"stat": 7, "amount": 155}], "name": "Truesteel Armguards of the Savage", "tooltipParams": {"timewalkerLevel": 100}, "armor": 141, "itemLevel": 640, "bonusLists": [83, 525, 534], "context": "trade-skill", "quality": 4, "id": 114236, "icon": "inv_plate_draenorcrafted_d_01bracer"}, "hands": {"stats": [{"stat": 32, "amount": 48}, {"stat": 49, "amount": 72}, {"stat": 74, "amount": 95}, {"stat": 7, "amount": 142}], "name": "Incarnadine Gauntlets", "tooltipParams": {"timewalkerLevel": 100}, "armor": 181, "itemLevel": 600, "bonusLists": [521], "context": "dungeon-level-up-4", "quality": 3, "id": 109856, "icon": "inv_glove_plate_draenordungeon_c_01"}, "tabard": {"stats": [], "name": "Argent Crusader\'s Tabard", "tooltipParams": {"timewalkerLevel": 100}, "armor": 0, "itemLevel": 1, "bonusLists": [], "context": "", "quality": 3, "id": 46874, "icon": "inv_shirt_guildtabard_01"}, "legs": {"stats": [{"stat": 4, "amount": 133}, {"stat": 32, "amount": 177}, {"stat": 7, "amount": 199}], "name": "Polished Legplates of Valor", "tooltipParams": {"timewalkerLevel": 100}, "armor": 256, "itemLevel": 605, "bonusLists": [583], "context": "vendor", "quality": 7, "id": 122251, "icon": "inv_pants_04"}, "waist": {"stats": [{"stat": 59, "amount": 51}, {"stat": 32, "amount": 55}, {"stat": 74, "amount": 80}, {"stat": 7, "amount": 120}], "name": "Cragplate Girdle", "tooltipParams": {"timewalkerLevel": 100}, "armor": 130, "itemLevel": 582, "bonusLists": [171], "context": "quest-reward", "quality": 3, "id": 114736, "icon": "inv_belt_plate_draenorquest95_b_01"}}'

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


<!DOCTYPE html>
<html>
  <head>
    <title>garrisonwowtrack</title>
    <link href="style.css" rel="stylesheet"><script src="script.js" type="text/javascript"></script>
    <div class="header">
      <h1>Crusader Galf</h1>
      <p>
        <img src="/imgs/getsdrawn-bw.png">
      </p>
      <p>bonusArmor</p>
      <p>109</p>
      <p>critRating</p>
      <p>855</p>
      <p>powerType</p>
      <p>runic-power</p>
      <p>multistrikeRating</p>
      <p>14.121212</p>
      <p>mainHandDps</p>
      <p>2041.5823</p>
      <p>int</p>
      <p>572</p>
      <p>leechRatingBonus</p>
      <p>0.0</p>
      <p>spr</p>
      <p>640</p>
      <p>spellCritRating</p>
      <p>855</p>
      <p>avoidanceRating</p>
      <p>0.0</p>
      <p>spellPower</p>
      <p>572</p>
      <p>rangedDps</p>
      <p>-1.0</p>
      <p>leechRating</p>
      <p>0.0</p>
      <p>crit</p>
      <p>12.772727</p>
      <p>mastery</p>
      <p>26.436363</p>
      <p>multistrike</p>
      <p>14.121212</p>
      <p>versatilityDamageDoneBonus</p>
      <p>2.184615</p>
      <p>armor</p>
      <p>2297</p>
      <p>avoidanceRatingBonus</p>
      <p>0.0</p>
      <p>spellCrit</p>
      <p>12.772727</p>
      <p>mana5Combat</p>
      <p>0.0</p>
      <p>mana5</p>
      <p>0.0</p>
      <p>health</p>
      <p>238740</p>
      <p>rangedDmgMax</p>
      <p>-1.0</p>
      <p>rangedDmgMin</p>
      <p>-1.0</p>
      <p>hasteRatingPercent</p>
      <p>7.777778</p>
      <p>leech</p>
      <p>0.0</p>
      <p>versatilityDamageTakenBonus</p>
      <p>1.092308</p>
      <p>dodge</p>
      <p>5.0</p>
      <p>power</p>
      <p>105</p>
      <p>spellPen</p>
      <p>0</p>
      <p>mainHandSpeed</p>
      <p>3.006</p>
      <p>attackPower</p>
      <p>3480</p>
      <p>speedRating</p>
      <p>0.0</p>
      <p>multistrikeRatingBonus</p>
      <p>4.121212</p>
      <p>hasteRating</p>
      <p>700</p>
      <p>masteryRating</p>
      <p>574</p>
      <p>blockRating</p>
      <p>0</p>
      <p>parry</p>
      <p>16.6417</p>
      <p>versatility</p>
      <p>284</p>
      <p>parryRating</p>
      <p>855</p>
      <p>dodgeRating</p>
      <p>0</p>
      <p>sta</p>
      <p>3979</p>
      <p>mainHandDmgMin</p>
      <p>5654.0</p>
      <p>speedRatingBonus</p>
      <p>0.0</p>
      <p>mainHandDmgMax</p>
      <p>6620.0</p>
      <p>agi</p>
      <p>1073</p>
      <p>offHandDps</p>
      <p>699.99756</p>
      <p>rangedSpeed</p>
      <p>-1.0</p>
      <p>versatilityHealingDoneBonus</p>
      <p>2.184615</p>
      <p>offHandDmgMax</p>
      <p>1169.0</p>
      <p>haste</p>
      <p>19.74112</p>
      <p>rangedAttackPower</p>
      <p>0</p>
      <p>str</p>
      <p>2965</p>
      <p>offHandDmgMin</p>
      <p>1168.0</p>
      <p>block</p>
      <p>0.0</p>
      <p>offHandSpeed</p>
      <p>1.67</p>
    </div>
  </head>
  <body></body>
</html>

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]:
246

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")


Aegwynn
Aerie Peak
Agamaggan
Aggramar
Akama
Alexstrasza
Alleria
Altar of Storms
Alterac Mountains
Aman'Thul
Andorhal
Anetheron
Antonidas
Anub'arak
Anvilmar
Arathor
Archimonde
Area 52
Argent Dawn
Arthas
Arygos
Auchindoun
Azgalor
Azjol-Nerub
Azralon
Azshara
Azuremyst
Baelgun
Balnazzar
Barthilas
Black Dragonflight
Blackhand
Blackrock
Blackwater Raiders
Blackwing Lair
Blade's Edge
Bladefist
Bleeding Hollow
Blood Furnace
Bloodhoof
Bloodscalp
Bonechewer
Borean Tundra
Boulderfist
Bronzebeard
Burning Blade
Burning Legion
Caelestrasz
Cairne
Cenarion Circle
Cenarius
Cho'gall
Chromaggus
Coilfang
Crushridge
Daggerspine
Dalaran
Dalvengyr
Dark Iron
Darkspear
Darrowmere
Dath'Remar
Dawnbringer
Deathwing
Demon Soul
Dentarg
Destromath
Dethecus
Detheroc
Doomhammer
Draenor
Dragonblight
Dragonmaw
Drak'Tharon
Drak'thul
Draka
Drakkari
Dreadmaul
Drenden
Dunemaul
Durotan
Duskwood
Earthen Ring
Echo Isles
Eitrigg
Eldre'Thalas
Elune
Emerald Dream
Eonar
Eredar
Executus
Exodar
Farstriders
Feathermoon
Fenris
Firetree
Fizzcrank
Frostmane
Frostmourne
Frostwolf
Galakrond
Gallywix
Garithos
Garona
Garrosh
Ghostlands
Gilneas
Gnomeregan
Goldrinn
Gorefiend
Gorgonnash
Greymane
Grizzly Hills
Gul'dan
Gundrak
Gurubashi
Hakkar
Haomarush
Hellscream
Hydraxis
Hyjal
Icecrown
Illidan
Jaedenar
Jubei'Thos
Kael'thas
Kalecgos
Kargath
Kel'Thuzad
Khadgar
Khaz Modan
Khaz'goroth
Kil'jaeden
Kilrogg
Kirin Tor
Korgath
Korialstrasz
Kul Tiras
Laughing Skull
Lethon
Lightbringer
Lightning's Blade
Lightninghoof
Llane
Lothar
Madoran
Maelstrom
Magtheridon
Maiev
Mal'Ganis
Malfurion
Malorne
Malygos
Mannoroth
Medivh
Misha
Mok'Nathal
Moon Guard
Moonrunner
Mug'thol
Muradin
Nagrand
Nathrezim
Nazgrel
Nazjatar
Nemesis
Ner'zhul
Nesingwary
Nordrassil
Norgannon
Onyxia
Perenolde
Proudmoore
Quel'Thalas
Quel'dorei
Ragnaros
Ravencrest
Ravenholdt
Rexxar
Rivendare
Runetotem
Sargeras
Saurfang
Scarlet Crusade
Scilla
Sen'jin
Sentinels
Shadow Council
Shadowmoon
Shadowsong
Shandris
Shattered Halls
Shattered Hand
Shu'halo
Silver Hand
Silvermoon
Sisters of Elune
Skullcrusher
Skywall
Smolderthorn
Spinebreaker
Spirestone
Staghelm
Steamwheedle Cartel
Stonemaul
Stormrage
Stormreaver
Stormscale
Suramar
Tanaris
Terenas
Terokkar
Thaurissan
The Forgotten Coast
The Scryers
The Underbog
The Venture Co
Thorium Brotherhood
Thrall
Thunderhorn
Thunderlord
Tichondrius
Tol Barad
Tortheldrin
Trollbane
Turalyon
Twisting Nether
Uldaman
Uldum
Undermine
Ursin
Uther
Vashj
Vek'nilash
Velen
Warsong
Whisperwind
Wildhammer
Windrunner
Winterhoof
Wyrmrest Accord
Ysera
Ysondre
Zangarmarsh
Zul'jin
Zuluhed

In [ ]:
realm = Realm(battlenet.UNITED_STATES, jsrez['name')

In [19]:
#Return all realms.

In [ ]:


In [ ]: