我正在使用rvest
。我想将结果转换为数据框:
> links <- pgsession %>% jump_to(urls[2]) %>% read_html() %>% html_nodes("a")
> links
{xml_nodeset (114)}
[1] <a href="/Mitglieder/Detail/1213412">Date</a>
[2] <a href="/Account/ChangePassword">Kennwort ändern</a>
[3] <a href="/Account/BenutzernamenAendern/124312234">Benutzernamen ändern</a>
[4] <a href="/Account/LogOff">Abmelden</a>
...
我使用了以下方法:
library(plyr)
ldply(xmlToList(links), data.frame)
Error in UseMethod("xmlSApply") :
no applicable method for 'xmlSApply' applied to an object of class "xml_nodeset"
df1 <- data.frame(character(13000))
df1 <- rbind(df1, data.frame(links ))# append to data.frame
然而,我遇到了一个错误:
Error in UseMethod("xmlSApply") :
no applicable method for 'xmlSApply' applied to an object of class "xml_nodeset"
有什么建议我做错了吗?
感谢您的回复!
data.frame(hrefs=as(links, "character"))
的翻译是什么? - lukeA