48 raise_for_httperror(resp)
49 dom = fromstring(resp.text)
50 word = extract_text(dom.xpath(word_xpath))
54 for dict_src
in dict_xpath:
55 for src
in dom.xpath(dict_src):
56 src_text = extract_text(src.xpath(
'.//span[@class="entry-head-title"]/text()')).strip()
59 for def_item
in src.xpath(
'.//div[contains(@class, "ribbon-element")]'):
60 if def_item.xpath(
'./div[@class="znacz"]'):
62 for def_sub_item
in def_item.xpath(
'./div[@class="znacz"]'):
63 def_sub_text = extract_text(def_sub_item).lstrip(
'0123456789. ')
64 sub_defs.append(def_sub_text)
65 src_defs.append((word, sub_defs))
67 def_text = extract_text(def_item).strip()
68 def_link = def_item.xpath(
'./span/a/@href')
69 if 'doroszewski' in def_link[0]:
70 def_text = f
"<a href='{def_link[0]}'>{def_text}</a>"
71 src_defs.append((def_text,
''))
73 definitions.append((src_text, src_defs))
79 for src
in definitions:
80 infobox += f
"<div><small>{src[0]}</small>"
82 for def_text, sub_def
in src[1]:
83 infobox += f
"<li>{def_text}</li>"
86 for sub_def_text
in sub_def:
87 infobox += f
"<li>{sub_def_text}</li>"
89 infobox +=
"</ul></div>"