【问题标题】:Web Scraping In R readHTMLTable error with functionR中的Web Scraping readHTMLTable错误与函数
【发布时间】:2019-11-28 20:48:58
【问题描述】:

我正在R 中自学一些基本的表格网络抓取技术。但是我在运行readHTMLTable函数时看到了错误。

找不到签名“NULL”的函数“readHTMLTable”的继承方法

我特别想读取第二个表中的数据。我已经检查了页面源以确保表格的格式为<table><td>

release_table <- readHTMLTable("https://www.comichron.com/monthlycomicssales/1997/
                               1997-01.html", header=TRUE, which=2,stringsAsFactors=F)

我希望输出反映第二个表中的文本。

【问题讨论】:

    标签: r web-scraping html-table


    【解决方案1】:

    我们可以使用rvest 来获取所有表格。

    url <- "https://www.comichron.com/monthlycomicssales/1997/1997-01.html"
    library(rvest)
    tab <- url %>%  read_html() %>%  html_table()
    

    我想你要找的是tab[[1]]tab[[4]]

    【讨论】:

    • 好一个罗纳克!很优雅!!
    猜你喜欢
    • 1970-01-01
    • 2012-08-25
    • 1970-01-01
    • 1970-01-01
    • 2016-08-06
    • 2021-07-13
    • 2020-04-08
    • 1970-01-01
    相关资源
    最近更新 更多