import httplib2 import urllib request from lxml import etree def creat

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import httplib2
import urllib.request
from lxml import etree
def create_armory_link(realm, name):
raw_link = 'http://eu.battle.net/wow/ru/character/'+realm+'/'+name+'/simple'
return httplib2.iri2uri(raw_link)
def get_armory_info(realm, name):
armory_info = []
armory = urllib.request.urlopen(create_armory_link(realm, name)).read()
page_tree = etree.HTML(armory)
class_icon = page_tree.xpath('//*[@id="summary-talents"]/div/div[1]/a[1]/span/span[2]/span/img')
race = page_tree.xpath('//*[@id="profile-wrapper"]/div[1]/div/div/div/div[1]/div/div[3]/a[1]')
char_class = page_tree.xpath('//*[@id="profile-wrapper"]/div[1]/div/div/div/div[1]/div/div[3]/a[2]')
char_ilvl = page_tree.xpath('//*[@id="summary-averageilvl-best"]')
armory_info.append(class_icon[0].get('src'))
armory_info.append(race[0].text)
armory_info.append(char_class[0].text)
armory_info.append(char_ilvl[0].text)
return armory_info
print(get_armory_info('бореиская-тундра', 'Свирм'))
['http://media.blizzard.com/wow/icons/36/spell_nature_healingtouch.jpg', 'ТÑ\x80оллÑ\x8c', \x94Ñ\x80Ñ\x83ид', '\n\t\t577\n\t']