Home > Software engineering >  Scrapy - selecting with custom attribute value
Scrapy - selecting with custom attribute value

Time:11-12

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?

CodePudding user response:

Yes, you use CSS Attribute Selectors.

For example:

response.css('div[data-testid="total-count"]::text').get()
  • Related