Issue
I would like to count the number of div (so 2) inside the div "thumb-container".
So far I have used css selectors so I would like to keep using css and not xpath:
yield {
'date':datetime.date.today(),
'title': response.css('h1::text').extract()[-1],
'rating':response.css('bl-rating::attr(rating)').get(),
}
Solution
getall() returns a list so you can get it's length.
With the code you provided (next time post it as text and not as image):
In [1]: len(response.css('div.thumb-container div').getall())
Out[1]: 2
Answered By - SuperUser
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.