Get startedGet started for free

Order CSS selectors by the number of results

Depending on how many HTML elements of the same type there are on a web page, CSS selectors will return a different number of nodes. It's always good to have a certain idea about the magnitude of specific queries. This way you recognize when there is a problem, e.g., if your code returns a lot less elements than expected.

Given almost the same HTML as before:

<html> 
  <body> 
    <div>Python is perfect for programming. 
      <span>It even works for scraping!</span>
    </div>
    <p>Still, R is better suited for data analysis. 
      <span>But scraping is also a breeze.</span>
    </p>
    <small>(It has prettier charts, too.)</small>
  </body> 
</html>

This exercise is part of the course

Web Scraping in R

View Course

Hands-on interactive exercise

Turn theory into action with one of our interactive exercises

Start Exercise