如何在Rvest中排除部分节点?过滤

时间:2019-03-21 08:22:16

标签: html r web-scraping rvest

我正在抓取页面:https://www.dr.dk/nyheder/allenyheder/politik/

我需要带头衔,但我需要排除其中一些头衔

我的代码是:

    # Defining URL
url <- "https://www.dr.dk/nyheder/allenyheder/politik/"

  dr.html <- read_html(final_url)

  titles1 <- dr.html %>%
    html_nodes(".heading-small h3 a>:not(.dr-list:nth-child(2) h3 a)") %>%
    html_text()

我需要节点.heading-small h3 a中的内容,但不包括.dr-list:nth-​​child(2)h3 a中的内容。

我的代码不起作用。

我收到消息:parse_simple_selector(stream)中的错误:预期为')',得到h3

谢谢

0 个答案:

没有答案
相关问题