Reputation: 314
I'm trying to use Xpath in order to select an HTML tag based on its value
Here is my html code:
<span class="yellowbird">Continue</span>
<span class="yellowbird">Stop</span>
I can select the span elements with a specific class value using
//span[contains(@class, 'yellowbird')]
However I'm struggling to select only the element which contains the value "Continue"
Upvotes: 0
Views: 87
Reputation: 314
Here is the syntax I used to make this work using request.xpath and scrapy
//span[contains(@class, 'yellowbird')][1]//text()='Continue'
Upvotes: 0
Reputation: 5443
This XPath expression will select any span
element whose class
attribute equals yellowbird
and text equals Continue
:
//span[@class='yellowbird' and text()='Continue']
Upvotes: 2