Introductie tot CSS

Webscraping in R

Timo Grossenbacher

Instructor

Cascading Style Sheets

h1 {
    color: red;
}
p {
    font-style: italic;
}
<html>
  <body>
    <h1>Welkom bij webscraping!</h1>
    <p>In R, Python of een 
      andere taal - 
      scrapen is leuk!</p>
  </body>
</html>
Webscraping in R

CSS-selectors

h1 {
  color: green;
}
p {
  font-style: italic;
}
h1, p {
  font-family: sans-serif;
}
...
    <h1>Nog een CSS-voorbeeld.</h1>
    <p>Wat tekst.</p>
...

Nog een CSS-voorbeeld

html %>% html_elements('h1, p')
{xml_nodeset (2)}
[1] <h1> Another CSS ex...
[2] <p>Some text</p>
Webscraping in R

Typeselectors

type {
    key: value;
}

html %>% html_elements('type') # bijv. 'h1' of 'a' of 'span'
type1, type2 {
    key: value;
}

html %>% html_elements('type1, type2')
* {
    key: value;
}

html %>% html_elements('*')
Webscraping in R

Laten we oefenen!

Webscraping in R

Preparing Video For Download...