Reputation: 63619
How can Scrapy be used to select the text of an element that has a particular attribute name and value?
For example,
<span property="city">Montreal</span>
I tried the following but received a None
response.css('.span[property="city"]::text').extract_first()
Upvotes: 20
Views: 11486
Reputation: 16619
You are making a small mistake. You need to drop the '.'
before 'span'
:
In [6]: response.css('span[property="city"]::text').extract_first()
Out[6]: u'Montreal'
Upvotes: 31