如何使用Splinter查找元素值? [英] How to find element value using Splinter?
本文介绍了如何使用Splinter查找元素值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下一段html:
I have following piece of html:
<p class="attrs"><span>foo:</span> <strong>foo</strong></p>
<p class="attrs"><span>bar:</span> <strong>bar</strong></p>
<p class="attrs"><span>foo2:</span> <strong></strong></p>
<p class="attrs"><span>description:</span> <strong>description body</strong></p>
<p class="attrs"><span>another foo:</span> <strong>foooo</strong></p>
我想使用裂片获得描述主体.我设法使用
列出了p
I would like to get description body using splinter. I've managed to get a list of p
using
browser.find_by_css("p.attrs")
推荐答案
xpath = '//p[@class="attrs"]/span[text()="description:"]/following-sibling::strong'
description = browser.find_by_xpath(xpath).first.text
这篇关于如何使用Splinter查找元素值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文