Scrapy – selecting with custom attribute value

Question:

I need to scrap some data not with CSS class but with custom atrribute value.

<div data-testid="total-count">We found 45 offers</div>

So I need something like that:

response.css('div.total-count::text').get()

Is it possible?

Asked By: dymek662

||

Answers:

Yes, you use CSS Attribute Selectors.

For example:

response.css('div[data-testid="total-count"]::text').get()
Answered By: Felix Eklöf
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.