如何在 R 中的列不一致时获取 html table 数据(rvest)

How to get html table data when columns are inconsistent in R (rvest)

我想从网站https://www.mohfw.gov.in/提取table数据 它具有 inconsistent 列结构,因此我无法轻松提取它。我已尝试如下,但我只能获得 header 详细信息,但无法获得 table.

中的实际数据
library(rvest)
url='https://www.mohfw.gov.in/'
webpage <- read_html(url)
table <- html_node(webpage, "table.statetable.table.table-striped")
frame <- html_table(table,fill = TRUE)

打开开发工具的网络选项卡并重新加载页面。您将看到页面从这个 JSON 文件加载数据:https://www.mohfw.gov.in/data/datanew.json

您可以通过以下方式阅读:

table <- jsonlite::fromJSON("https://www.mohfw.gov.in/data/datanew.json")