adam.888
adam.888

Reputation: 7846

webscraping data tables and data from a web page

I am trying to webscrape real time streaming data tables and data from a web page I tried:

library(XML)
webpage  <- "http://www.investing.com/indices/us-30"

tables <- readHTMLTable(webpage )
n.rows <- unlist(lapply(tables, function(t) dim(t)[1]))

tables
n.rows

but I get an error.

Thank you for your help.

Upvotes: 0

Views: 853

Answers (1)

ASH
ASH

Reputation: 20342

I'm actually proud of myself for getting this to work (I have been trying to get my head around these kinds of things for a long time now....)

library(rvest)
url4 <- "http://www.investing.com/indices/us-30-historical-data"

yourdata <- url4 %>% read_html() %>% 
html_nodes(xpath = '//*[@id="results_box"]/table[1]') %>% 
html_table()   

yourdata <- as.data.frame(yourdata)

Upvotes: 1

Related Questions