问题描述
以这种格式:
df1 <- data.frame(id = c(1,2),text = c("<h1> Title </h1> keep me here <h1>not </h1> or <h2> else</h2>","also not here <h1> but</h1> here also")
如何将df1文本列的第一行读取为html以便接收h1标签的内部文本。
这是我尝试过的:
library(rvest)
rawHTML <- paste(df1$text[1],collapse="\n")
rawHTML %>%
html_node("h1") %>%
html_text() %>%
as.numeric()
错误:
Error in UseMethod("xml_find_first") :
no applicable method for 'xml_find_first' applied to an object of class "character"
使用完整数据帧的预期输出
data.frame(id = c(1,title = c("keep me here",0))
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)