0

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":

code screenshot

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:

code screenshot

2
  • 1
    I think your main mistake was missing the ending square bracket after portefeuille_bloc. Commented Dec 3, 2019 at 14:44
  • Ooops.. yes. Thanks! Commented Dec 3, 2019 at 14:44

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

Try this:

response.css('#portefeuille_bloc ::attr(href)').extract()

There is no need to use HTML tags with ids and classes.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.