Good evening, guys!
I am trying to get the balance sheet, income statement and cash flow from Yahoo Finance (https://finance.yahoo.com/quote/AMZN/financials).
This is the code that I already have:
# Loads the rvest, stringr, and dplyr libraries
library(rvest)
library(stringr)
library(dplyr)
# Defines the Unicorn Auctions URL (past auctions)
url <- paste0("https://finance.yahoo.com/quote/AMZN/financials")
# Scrape the auction data
BS <-
# Read HTML content from the specified URL
read_html(url) %>%
# Extract the script element containing auction data using XPath 'auction_data ='
html_nodes("script") %>%
html_text() %>%
.[48]
start = gregexpr("context",BS)[[1]][1]-2
end = nchar(BS)-12
BS <- substr(BS,start,end)
BS <- jsonlite::fromJSON(BS)
BS$context$dispatcher$stores
I followed an Youtube video, but I saw that after 2023 the Yahoo web site has changed and this code doesnt work anymore.
In the video this code would get all the balance sheet and cash flow data.
But the output that I receive is this: Code output
Could someone please help me? I know that there's some similar questions, but after 2023 the website changed and their answers doesn't work anymore.
I have been able to extract the table with the following code :