Shilpa Rai Shilpa Rai - 1 year ago 63
R Question

Web scrape data from finance website using R (rvest)

I am trying to scrape data from ADM finance. I am using

rvest
library of
R
to pull the data. Below is the code, I am running

library(rvest)
url ="https://www.e-adm.com/futr/futr_composite_window.asp"
table1 = html(url) %>% html_nodes(".miniText tr:nth-child(1) td:nth-child(1) .smTextBlk") %>% html_nodes("table") %>%html_table
table2 = html(url) %>% html_nodes(".miniText tr:nth-child(1) td:nth-child(2) .smTextBlk") %>% html_nodes("table") %>%html_table


and getting following warning message with no data

Warning message:
'html' is deprecated.
Use 'read_html' instead.
See help("Deprecated")


My objective is to pull all the tables from this website. It would be a great help if anyone can help me with code. Thanks in advance!

Answer Source
library(rvest)
url ="https://www.e-adm.com/futr/futr_composite_window.asp"

tableList <- read_html(url) %>% 
    html_nodes(".miniText") %>% 
    html_nodes("td table") %>% 
    html_table()

This creates a list of the 9 tables in the linked website.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download