我正在使用以下代码,该代码获取了Google的年度收入表。我正在尝试对其进行修改以获取“季度”帐户,但是“年度”和“季度”的链接相同。我是否认为我应该更改一些内容,以便从以下代码行下载表:html_nodes(xpath = '//*[@id="Col1-1-Financials-Proxy"]/section/div[3]/table')
代码:
symbols <- "GOOG"
url <- "https://finance.yahoo.com/quote/"
url <- paste0(url,symbols,"/financials?p=",symbols)
url
wahis.session <- html_session(url)
p <- wahis.session %>%
html_nodes(xpath = '//*[@id="Col1-1-Financials-Proxy"]/section/div[3]/table')%>%
html_table(fill = TRUE)
p
IS <- p[[1]]
colnames(IS) <- paste(IS[1,])
IS <- IS[-c(1,5,12,20,25),]
names_row <- paste(IS[,1])
IS <- IS[,-1]
IS <- apply(IS,2,function(x){gsub(",","",x)})
IS <- as.data.frame(apply(IS,2,as.numeric))