Home > other >  How can I extract this specific table from this web page using R?
How can I extract this specific table from this web page using R?

Time:01-01

I am trying to extract a table from a specific webpage but I am not getting any results from my codes.

My codes stand as follows:

library(rvest)
library(dplyr)

url1<-"https://finance.yahoo.com/quote/SKLZ/cash-flow?p=SKLZ"

url_page<- read_html(url1)

listings <- html_nodes(url_page, css = '.Pos')

The table I am interested to extract falls under the (after doing an "inspect" in Chrome).

Here is a screenshot of the table:

screenshot

Any help would be appreciated.

CodePudding user response:

[QHarr] has answered the same question in this post I've copied the relevant code from their answer.

library(rvest)
library(stringr)
library(magrittr)

page <- read_html("https://finance.yahoo.com/quote/SKLZ/cash-flow?p=SKLZ")
nodes <- page %>%html_nodes(".fi-row")
df = NULL

for(i in nodes){
  r <- list(i %>%html_nodes("[title],[data-test='fin-col']")%>%html_text())
  df <- rbind(df,as.data.frame(matrix(r[[1]], ncol = length(r[[1]]), byrow = TRUE), stringsAsFactors = FALSE))
}

df
  • Related