32 raise_for_httperror(resp)
33 dom = fromstring(resp.text)
34 word = extract_text(dom.xpath(
'//*[@id="headword"]/text()'))
37 for src
in dom.xpath(
'//*[@id="define"]//h3[@class="source"]'):
38 src_text = extract_text(src).strip()
39 if src_text.startswith(
'from '):
40 src_text = src_text[5:]
43 for def_item
in src.xpath(
'following-sibling::ul[1]/li'):
44 def_abbr = extract_text(def_item.xpath(
'.//abbr')).strip()
45 def_text = extract_text(def_item).strip()
47 def_text = def_text[len(def_abbr) :].strip()
48 src_defs.append((def_abbr, def_text))
50 definitions.append((src_text, src_defs))
56 for src_text, src_defs
in definitions:
57 infobox += f
"<small>{src_text}</small>"
59 for def_abbr, def_text
in src_defs:
62 infobox += f
"<li><i>{def_abbr}</i> {def_text}</li>"