使用 rvest 将刮取的表存储到变量中 [英] storing scraped table using rvest in to a variable

查看:41
本文介绍了使用 rvest 将刮取的表存储到变量中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将我从 html_table 获得的输出存储到变量中?:

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)

推荐答案

最小示例:

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)

这篇关于使用 rvest 将刮取的表存储到变量中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆