这是我正在运行的代码
library(rvest)
rootUri <- "https://github.com/rails/rails/pull/"
PR <- as.list(c(100, 200, 300))
list <- paste0(rootUri, PR)
messages <- lapply(list, function(l) {
html(l)
})
到目前为止,它似乎工作正常,但是当我尝试提取文本时:
html_text(messages)
我得到:
Error in xml_apply(x, XML::xmlValue, ..., .type = character(1)) :
Unknown input of class: list
尝试提取特定元素:
html_text(messages[1])
也不能这样...
Error in xml_apply(x, XML::xmlValue, ..., .type = character(1)) :
Unknown input of class: list
所以我尝试了一种不同的方式:
html_text(messages[[1]])
这似乎至少得到了数据,但仍然没有成功:
Error in UseMethod("xmlValue") :
no applicable method for 'xmlValue' applied to an object of class "c('HTMLInternalDocument', 'HTMLInternalDocument', 'XMLInternalDocument', 'XMLAbstractDocument')"
如何从列表的每个元素中提取文本材料?