[英]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 我希望从示例URL https://www.valueresearchonline.com/funds/fundSelector/returns.asp?cat=10&exc=susp%2Cclose&rettab=st提取具有排名和回报的表格
So far tried rvest 到目前为止尝试过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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.