michaelBard
michaelBard

Reputation: 1

Xpath text between tags

Any idea how i would get the text between 2 tags using Xpath code? specifically the 3, bd, 1, ba.

<p class="MuiTypography-root RoofCard__RoofCardNameStyled-niegej-8 hukPZu MuiTypography-body1" xpath="1">

<span class="NumberFormatWithStyle__NumberFormatStyled-sc-1yvv7lw-0 jVQRaZ inline-block md">$65,000</span></p>

**"3" == $0
" bd, " == $0
"1" == $0
" ba | " == $0**

<span class="NumberFormatWithStyle__NumberFormatStyled-sc-1yvv7lw-0 jVQRaZ inline-block md" xpath="1">926</span>

tried:

Upvotes: 0

Views: 69

Answers (1)

gangabass
gangabass

Reputation: 10666

In fact from your sample that's a simple text() node after p:

//p/following-sibling::text()[1]

but of course you'll need to parse it. This will return almost that you need:

values = response.xpath('//p/following-sibling::text()[1]').re(r'"([^"]+)"')

Upvotes: 1

Related Questions