我感觉很笨。Python & xpath 新手在这里。我正在尝试'Open Box Price: $1079.99'
使用 xpath 从
<div class="prod-price">
<p class="opbox-price">
<strong> Open Box Price:<br>$1079.99</strong>
</p>
<p class="orig-price">
Regular Price: <strong>$1499.98</strong>
</p>
</div>
但我不能。文本停在<br>
. 这是我的代码
doc = lxml.html.fromstring(r.content)
elements = doc.xpath(item_xpath)
print elements[1].find('div[3]/p[1]/text()[normalize-space()]')