识别要抓取的Web表格式

问题描述 投票:0回答:1

这对我有用:

library(XML)
tables       <-  readHTMLTable("http://cdec.water.ca.gov/reportapp/javareports?name=FNF", as.data.frame = TRUE)
bottom_table <-  tables[[2]]
# process bottom_table's data, deploy to Shiny app

但是当我使用https而不是http时:

tables       <-  readHTMLTable("https://cdec.water.ca.gov/reportapp/javareports?name=FNF", as.data.frame = TRUE)
# Warning: XML content does not seem to be XML`

所以,我想学习如何识别表的内容类型以及用于刮擦和保留表格式的R库/函数。感谢您的提示。

r xml rvest
1个回答
0
投票

有R函数来确定数据帧的类和维,这是预期的readHTMLTable使用您提供的as.data.frames参数传递的。

?readHTMLTable
> class(bottom_table)
#[1] "data.frame"
> dim(bottom_table)
#[1] 40  9

也:

?rownames
?colnames
© www.soinside.com 2019 - 2024. All rights reserved.