简体   繁体   中英

Web scraping in R with rvest and XML2 extract table

I wish to extract the table with the ranks and returns from a sample URL https://www.valueresearchonline.com/funds/fundSelector/returns.asp?cat=10&exc=susp%2Cclose&rettab=st

So far tried rvest

#Reading the HTML code from the website
webpage <- read_html(urlString)

#Using CSS selectors to scrap the section
tables <- webpage %>% html_node("tr") %>% html_text()
tables <- html_node(".fundtool_cat") %>% html_text()

I need a dataframe/table with name of the scheme along with ranks and returns for all periods mentioned Any help would be appreciated.

Hope this helps!

library(rvest)
urlString <- "https://www.valueresearchonline.com/funds/fundSelector/returns.asp?cat=10&exc=susp%2Cclose&rettab=st"
urlString %>%
  read_html() %>%
  html_nodes(xpath='//*[@id="fundCatData"]/table[1]') %>%
  html_table(fill=T)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM