storing scraped table using rvest in to a variable

2019-09-19 18:09发布

how do I store the output I get from html_table into a variable?:

  library(rvest)


   elec<- 
   read_html("https://en.wikipedia.org/wiki/Botswana_general_election,_1969")

    elec%>%

   html_nodes("table.wikitable")%>% 
   html_table(fill=TRUE)

标签: r rvest
1条回答
等我变得足够好
2楼-- · 2019-09-19 18:36

Minimal example:

library(rvest)

    data <- read_xml("url")


    a <- data %>% xml_find_all("//node a") %>% xml_text() 
    b <- data %>% xml_find_all("//node b") %>% xml_text()

    df =  data.frame(a,b)
查看更多
登录 后发表回答