Giới thiệu về CSS

Web Scraping bằng 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 bằng R

Bộ chọn CSS

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

Một ví dụ CSS khác

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

Bộ chọn theo kiểu

type {
    key: value;
}

html %>% html_elements('type') # ví dụ: 'h1' hoặc 'a' hoặc 'span'
type1, type2 {
    key: value;
}

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

html %>% html_elements('*')
Web Scraping bằng R

Hãy bắt đầu!

Web Scraping bằng R

Preparing Video For Download...