Get class name using Scrapy
Question:
Answers:
Rating isn’t text node value rather attribute value.So You have to invoke ::attr(rating)
instead of ::text
to get that value as string/text.
'rating':product.css('bl-rating::attr(rating)').get()
Using an xpath expression:
After iterating over an array/list of elements, the subsequent xpath expression would be a relative expression (.//
)
'rating':product.xpath('.//bl-rating/@rating').get()
This is more for anyone who might find this answer in the future.
You can also extract the rating
value using an xpath
expression.
For Example:
'rating': response.xpath('//bl-rating/@rating').get()
Rating isn’t text node value rather attribute value.So You have to invoke ::attr(rating)
instead of ::text
to get that value as string/text.
'rating':product.css('bl-rating::attr(rating)').get()
Using an xpath expression:
After iterating over an array/list of elements, the subsequent xpath expression would be a relative expression (.//
)
'rating':product.xpath('.//bl-rating/@rating').get()
This is more for anyone who might find this answer in the future.
You can also extract the rating
value using an xpath
expression.
For Example:
'rating': response.xpath('//bl-rating/@rating').get()