User:AdamWeeden/poxnora2wiki.py

import urllib

def pickData(data, after, leftend, rightend): try: return data.split(after)[1].split(leftend)[1].split(rightend)[0] except IndexError: return ''

def rune_compare(x, y): if(x[0]>y[0]): return 1 elif(x[0]-1): finished = 1 else: name = pickData(runedata,'',' ') noracost = pickData(runedata,'Nora Cost',' ','<') attack = pickData(runedata,'Attack',' ','<') defense = pickData(runedata, 'Defense',' ',' ') speed = pickData(runedata, 'Speed', ' ', ' ') range = pickData(runedata, 'Range', ' ', ' ') damage = pickData(runedata, 'Damage', ' ', ' ') hitpoints = pickData(runedata, 'Hit Points', ' ', ' ') factions = pickData(runedata, 'Faction', ' ', ' ') rarity = pickData(pickData(runedata, 'Rarity', ''),'=', '>', '<') abilities = [] currability = pickData(pickData(runedata, 'store_abilities', 'center;">', '', '', '', '</a').strip currrune = [] currrune.append(name) currrune.append(noracost) currrune.append(attack) currrune.append(defense) currrune.append(speed) currrune.append(range) currrune.append(damage) currrune.append(hitpoints) currrune.append(factions) currrune.append(rarity) currrune.append(abilities) runes.append(currrune) currid += 1

runes.sort(rune_compare)

table='===Champions===\n\n{| class="wikitable"\n|-\n!Name!!Nora Cost!!Attack!!Defense!!Speed!!Range!!Damage!!Hit Points!!Faction!!Rarity\n'

for rune in runes: table += '|-\n|'+rune[0]+'||'+rune[1]+'||'+rune[2]+'||'+rune[3]+'||'+rune[4]+'||'+rune[5]+'||'+rune[6]+'||'+rune[7]+'||'+rune[8]+'||' if(rune[9]=='Common'): table += 'style="color:goldenrod;"|Common||' elif(rune[9]=='Uncommon'): table += 'style="color:red;"|Uncommon||' elif(rune[9]=='Rare'): table += 'style="color:blue;"|Rare||' elif(rune[9]=='Exotic'): table += 'style="color:purple;"|Exotic||' else: table += rune[9]+'||' if len(rune[10])>0: table += '' for ability in rune[10]: table += ''+ability+'' table += '' table += '\n'

table += '|}'

print table

currid = 1 finished = 0 runes = []

while (not finished): rune = urllib.urlopen('http://www.poxnora.com/store/frontPreviewAjax.do?i='+str(currid)+'&t=S') runedata = rune.read if (runedata.find('HTTP Status 500')>-1): finished = 1 else: name = pickData(runedata,'',' ') description = pickData(runedata,'Description','">','<')       noracost = pickData(runedata,'Nora Cost',' ','<')        cooldown = pickData(runedata,'Cooldown',' ','<')        factions = pickData(runedata, 'Faction', ' ', ' ')        rarity = pickData(pickData(runedata, 'Rarity', ''),'=', '>', '<')        currrune = []        currrune.append(name)        currrune.append(noracost)        currrune.append(description)        currrune.append(cooldown)        currrune.append(factions)        currrune.append(rarity)        runes.append(currrune)    currid += 1

runes.sort(rune_compare)

table='\n===Spells===\n\n{| class="wikitable"\n|-\n!Name!!Nora Cost!!style="width:450px;"|Description!!Cooldown||Faction!!Rarity\n'

for rune in runes: table += '|-\n|'+rune[0]+'||'+rune[1]+'||'+rune[2]+'||'+rune[3]+'||'+rune[4]+'||' if(rune[5]=='Common'): table += 'style="color:goldenrod;"|Common' elif(rune[5]=='Uncommon'): table += 'style="color:red;"|Uncommon' elif(rune[5]=='Rare'): table += 'style="color:blue;"|Rare' elif(rune[5]=='Exotic'): table += 'style="color:purple;"|Exotic' else: table += rune[5] table += '\n'

table += '|}'

print table

currid = 1 finished = 0 runes = []

while (not finished): rune = urllib.urlopen('http://www.poxnora.com/store/frontPreviewAjax.do?i='+str(currid)+'&t=R') runedata = rune.read if (runedata.find('HTTP Status 500')>-1): finished = 1 else: name = pickData(runedata,'',' ') description = pickData(runedata,'Description','">','<')       noracost = pickData(runedata,'Nora Cost',' ','<')        factions = pickData(runedata, 'Faction', ' ', ' ')        rarity = pickData(pickData(runedata, 'Rarity', ''),'=', '>', '<')        currrune = []        currrune.append(name)        currrune.append(noracost)        currrune.append(description)        currrune.append(factions)        currrune.append(rarity)        runes.append(currrune)    currid += 1

runes.sort(rune_compare)

table='\n===Relics===\n\n{| class="wikitable"\n|-\n!Name!!Nora Cost!!style="width:450px;"|Description!!Faction!!Rarity\n'

for rune in runes: table += '|-\n|'+rune[0]+'||'+rune[1]+'||'+rune[2]+'||'+rune[3]+'||' if(rune[4]=='Common'): table += 'style="color:goldenrod;"|Common' elif(rune[4]=='Uncommon'): table += 'style="color:red;"|Uncommon' elif(rune[4]=='Rare'): table += 'style="color:blue;"|Rare' elif(rune[4]=='Exotic'): table += 'style="color:purple;"|Exotic' else: table += rune[4] table += '\n'

table += '|}'

print table

currid = 1 finished = 0 runes = []

while (not finished): rune = urllib.urlopen('http://www.poxnora.com/store/frontPreviewAjax.do?i='+str(currid)+'&t=E') runedata = rune.read if (runedata.find('HTTP Status 500')>-1): finished = 1 else: name = pickData(runedata,'',' ') description = pickData(runedata,'Description','">','<')       noracost = pickData(runedata,'Nora Cost',' ','<')        factions = pickData(runedata, 'Faction', ' ', ' ')        rarity = pickData(pickData(runedata, 'Rarity', ''),'=', '>', '<')        currrune = []        currrune.append(name)        currrune.append(noracost)        currrune.append(description)        currrune.append(factions)        currrune.append(rarity)        runes.append(currrune)    currid += 1

runes.sort(rune_compare)

table='\n===Equipment===\n\n{| class="wikitable"\n|-\n!Name!!Nora Cost!!style="width:450px;"|Description!!Faction!!Rarity\n'

for rune in runes: table += '|-\n|'+rune[0]+'||'+rune[1]+'||'+rune[2]+'||'+rune[3]+'||' if(rune[4]=='Common'): table += 'style="color:goldenrod;"|Common' elif(rune[4]=='Uncommon'): table += 'style="color:red;"|Uncommon' elif(rune[4]=='Rare'): table += 'style="color:blue;"|Rare' elif(rune[4]=='Exotic'): table += 'style="color:purple;"|Exotic' else: table += rune[4] table += '\n'

table += '|}'

print table