Reputation: 33
I'm trying to understand how CSS selectors work using Scrapy. but I definitely don't understand to navigate in several html tag. For example, I'm trying to extract all the href link in the div id "portefeuille_bloc":
I tried this code but I can't identify where the mistake is:
response.css('div[id=portefeuille_bloc a::attr(href)').extract()
Furthermore, I tried to go deeper in the structure, and get all the h3 tag in the sub-division "portefeuille_bloc_bloc:
Upvotes: 0
Views: 637
Reputation: 805
Try this:
response.css('#portefeuille_bloc ::attr(href)').extract()
There is no need to use HTML tags with ids
and classes
.
Upvotes: 0
Reputation: 8784
Try this:
response.css('div#portefeuille_bloc a::attr(href)').getall()
See this doc page for more ideas:
https://docs.scrapy.org/en/latest/topics/selectors.html
Upvotes: 1