如何使用 R 从网站中提取表格数据
How to extract tabular data from a website using R
我正在尝试从网页中提取数据
https://www.geojit.com/other-market/world-indices
和许多其他类似的东西。
我需要获取网站的表格数据(INDEX、NAME、COUNTRY、CLOSE、PREV.CLOSE、NET CHANGE、CHANGE (%)、LAST UPDATED DATE & TIME)。如果您可以为此共享 R 代码或任何帮助,那就太好了。
library(rvest)
library(dplyr)
google <- html("https://www.geojit.com/other-market/world-indices")
google %>%
html_nodes()
library(rvest)
my_tbl <- read_html("https://www.geojit.com/other-market/world-indices") %>%
html_nodes(xpath = "//*[@id=\"aboutContent\"]/div[2]/table") %>%
html_table(header = TRUE) %>%
`[[`(1)
我正在尝试从网页中提取数据 https://www.geojit.com/other-market/world-indices 和许多其他类似的东西。
我需要获取网站的表格数据(INDEX、NAME、COUNTRY、CLOSE、PREV.CLOSE、NET CHANGE、CHANGE (%)、LAST UPDATED DATE & TIME)。如果您可以为此共享 R 代码或任何帮助,那就太好了。
library(rvest)
library(dplyr)
google <- html("https://www.geojit.com/other-market/world-indices")
google %>%
html_nodes()
library(rvest)
my_tbl <- read_html("https://www.geojit.com/other-market/world-indices") %>%
html_nodes(xpath = "//*[@id=\"aboutContent\"]/div[2]/table") %>%
html_table(header = TRUE) %>%
`[[`(1)