ComeçarComece de graça

Select the last child with a pseudo-class

In the following HTML showing the author of a text in the last paragraph, there are two groups of p nodes:

<html>
  <body>
    <div>
      <p class = 'text'>A sophisticated text [...]</p>
      <p class = 'text'>Another paragraph following [...]</p>
      <p class = 'text'>Author: T.G.</p>
    </div>
    <p>Copyright: DC</p>
  </body>
</html>

In this exercise, your job is to select the last p node within the div.

As you learned in the video, pseudo-classes can help you whenever you don't have other means of selecting a specific node of page, e.g., through an ID selector or a unique class.

The above HTML document is provided to you through the nested_html variable (already read in via read_html()).

Este exercício faz parte do curso

Web Scraping in R

Ver curso

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Select the last child of each p group
nested_html %>%
	___
Editar e executar o código