Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find element value using Splinter?

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>

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")
like image 643
pixel Avatar asked Jan 11 '23 05:01

pixel


1 Answers

xpath = '//p[@class="attrs"]/span[text()="description:"]/following-sibling::strong'
description = browser.find_by_xpath(xpath).first.text
like image 135
thinker3 Avatar answered Jan 21 '23 05:01

thinker3