R 语言网页抓取
Timo Grossenbacher
Instructor
h1 {
color: red;
}
p {
font-style: italic;
}
<html>
<body>
<h1>欢迎学习网络爬虫!</h1>
<p>无论用 R、Python,或任何其他语言,
爬虫都很有趣!</p>
</body>
</html>
h1 {
color: green;
}
p {
font-style: italic;
}
h1, p {
font-family: sans-serif;
}
...
<h1>另一个 CSS 示例。</h1>
<p>一些文本。</p>
...

html %>% html_elements('h1, p')
{xml_nodeset (2)}
[1] <h1> Another CSS ex...
[2] <p>Some text</p>
type { key: value; }html %>% html_elements('type') # 例如 'h1'、'a' 或 'span'
type1, type2 { key: value; }html %>% html_elements('type1, type2')
* { key: value; }html %>% html_elements('*')
R 语言网页抓取