CommencerCommencer gratuitement

How many elements get returned?

Given the following (unnecessarily complex) HTML…

<html>
  <body>
    <div class="first section">
      Some text with a <a href="#">link</a>.
    </div>
    <div class="second section">
      Some text with <a href="#">another link</a>.
      <div class="first paragraph">Some text.</div>
      <div class="second paragraph">Some more text.
        <div>...</div>
      </div>
    </div>
  </body>
</html>

…how many HTML element nodes are returned with the (unnecessarily verbose) .first + .second > div, div.second.paragraph > div selector?

The objective here is that you learn to deal with more and more complex selectors. Together with the next exercise, you'll discover how to make these selectors as simple and elegant as possible. Copy/paste the HTML to the console on the right and read it in!

Cet exercice fait partie du cours

Web Scraping in R

Afficher le cours

Exercice interactif pratique

Passez de la théorie à la pratique avec l’un de nos exercices interactifs

Commencer l’exercice