Crypto
Crypto

Reputation: 1227

Extracting a <span> tag that contains a text

I'm trying to extract a span tag like this:

<span>Price: $500</span>

What's wrong with doc.xpath('//span[@contains(text(), "Price")]/text()')?

It's saying it's an invalid expression.

Upvotes: 0

Views: 459

Answers (1)

Gilles Qu&#233;not
Gilles Qu&#233;not

Reputation: 185640

Try this :

//span[starts-with(name(), 'Price')]/text()

or

//span[starts-with(., 'Price')]/text()

or

//span[contains(., 'Price')]/text()

or

//span[contains(name(), 'Price')]/text()

Upvotes: 1

Related Questions