无法用 rvest 抓取 table

Can't scrape a table with rvest

我一直在尝试从此页面抓取 table:https://ficeda.com.mx/index.php?id=precios

我的代码是这样的

url_data <- "https://ficeda.com.mx/index.php?id=precios"

url_data %>% 
  read_html() %>% 
  html_node(xpath = "/html/body/div[1]/div/div/div[3]/table[1]") %>% 
  html_table()

但它给了我这个错误:UseMethod("html_table") 中的错误: 没有适用于 'html_table' 的方法应用于 class 的对象“xml_missing”

有人知道会发生什么吗?

谢谢!

该数据实际上位于 iframe 中。或者,发出初始请求并从 iframe 中提取 src link,然后在那里发出请求,或者直接向 iframe 文档发出请求:

library(rvest)

url_data <- "https://www.ficeda.com.mx/app_precios/pages/index/v2"

url_data %>% 
  read_html() %>% 
  html_node('.category_title + table') %>% 
  html_table()

来自原始端点的 iframe src:

read_html('https://ficeda.com.mx/index.php?id=precios') %>% html_node('#linea2') %>% html_attr('src')