Scrapping yahoo finance with data on several pages

38 Views Asked by At

I am trying to get every company that announces, on a given day, financial earnings reports. The objective is to scrap yahoo finance, which has a special page for that. Here is my code:

library(XML)

url <- paste('https://finance.yahoo.com/calendar/earnings?day=2024-03-07')

webpage <- readLines(url)
html <- htmlTreeParse(webpage, useInternalNodes = TRUE, asText = TRUE)
tableNodes <- getNodeSet(html, "//table")

a <- readHTMLTable(tableNodes[[1]])

The variable a contains all relevant information. The problem is that it lists the first 100 companies only, the others are to be found here and here.

My question is thus to find a smart way/trick to scrap all information in one single command, without wondering about how many companies are announcing on a single day.

0

There are 0 best solutions below