Pengantar CSS

Web Scraping di 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 di R

Selector CSS

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

Contoh CSS lain

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

Selector tipe

type {
    key: value;
}

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

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

html %>% html_elements('*')
Web Scraping di R

Ayo berlatih!

Web Scraping di R

Preparing Video For Download...