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!
This exercise is part of the course
Web Scraping in R
Hands-on interactive exercise
Turn theory into action with one of our interactive exercises
