what's wrong with my R code? -
i struggling parse contents html using htmltreeparse , xpath. below web link need extract information of "most valuable brands" , create data frame out of it. http://www.forbes.com/powerful-brands/list/#tab:rank
as first step towards building table, trying extract list of brands (apple, google, microsoft etc. ). trying through below code:
library(xml) htmlcontent <- geturl("http://www.forbes.com/powerful-brands/list/#tab:rank", ssl.verifypeer=false) htmlparsed <- htmltreeparse(htmlcontent, useinternal = true) output <- xpathsapply(htmlparsed, "/html/body/div/div/div/table[@id='the_list']/tbody/tr/td[@class='name']", xmlvalue)
but returning null. not able find mistake. "/html/body/div/div/div/table[@id='the_list']/thead/tr/th"
works correctly, returning ("", "rank", "brand" etc.) means path upto table correct. not able understand what's wrong thereafter.
Comments
Post a Comment