我正在抓取报纸文章,正在努力弄清楚如何排除多个节点。 R 帮助说
:not()
接受一系列简单选择器。我尝试了以下
zeit_url <- read.html("http://www.zeit.de/wissen/gesundheit/2017-09/aids-hiv-neuinfektionen-europa-virus-gesundheit")
article <- zeit_url %>%
html_nodes('.article-page>:not(.ad-container, .cardstack)') %>%
html_text()
用逗号分隔两个节点是不起作用的。有什么建议如何正确指定
:not()
中的选择器顺序吗?
我花了很多时间寻找答案,但我是 R(和 HTML)新手,所以如果这是显而易见的事情,我感谢您的耐心。
library(rvest)
zeit_url <- read_html("http://www.zeit.de/wissen/gesundheit/2017-
09/aids-hiv-neuinfektionen-europa-virus-gesundheit")
article <- zeit_url %>%
html_nodes(".article-page>:not(.ad-container):not(.cardstack)") %>%
html_text()