Introduzione al CSS

Web scraping in R

Timo Grossenbacher

Instructor

Cascading Style Sheets

h1 {
    color: red;
}
p {
    font-style: italic;
}
<html>
  <body>
    <h1>Welcome to Web Scraping!</h1>
    <p>Be it in R, Python or any 
      other language - 
      scraping is fun!</p>
  </body>
</html>
Web scraping in R

Selettori CSS

h1 {
  color: green;
}
p {
  font-style: italic;
}
h1, p {
  font-family: sans-serif;
}
...
    <h1>Another CSS example.</h1>
    <p>Some text.</p>
...

Un altro esempio CSS

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

Selettori di tipo

type {
    key: value;
}

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

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

html %>% html_elements('*')
Web scraping in R

Facciamolo!

Web scraping in R

Preparing Video For Download...