Python BeautifulSoup find element that contains text -
<div class="info"> <h3> height: <span>1.1</span> </h3> </div> <div class="info"> <h3> number: <span>111111111</span> </h3> </div>
this partial portion of site. ultimately, want extract 111111111. know can soup.find_all("div", { "class" : "info" })
list of both divs; however, prefer not have perform loop check if contains text "number".
is there more elegant way extract "1111111" soup.find_all("div", { "class" : "info" })
, makes must contain "number" within?
i tried numbersoup = soup.find('h3', text='number')
returns none
use xpath contains
:
root.xpath('//div/h3[contains(text(), "number")]/span/text()')
Comments
Post a Comment