我正在使用rvest
。我想結果轉換爲數據幀:將xml_nodeset轉換爲data.frame
> 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