Evan Strom
Evan Strom

Reputation: 75

How to extract tabular data from a website using R

I am trying to extract the data from the webpage https://www.geojit.com/other-market/world-indices and many others similar to this.

I need to get the tabular data of the website (INDEX,NAME,COUNTRY,CLOSE,PREV.CLOSE,NET CHANGE,CHANGE (%),LAST UPDATED DATE & TIME). would be great if you can share the R code for this or any help would be welcome.

library(rvest)
library(dplyr)   
google <- html("https://www.geojit.com/other-market/world-indices")    
google %>%    
html_nodes()

Upvotes: 3

Views: 417

Answers (1)

Ramiro Magno
Ramiro Magno

Reputation: 3175

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)

Upvotes: 2

Related Questions