I used RSelenium to press those plus signs to expand the table. Here is my try:
library(rvest)
library(Rselenium)
# initialize RSelenium
selCommand <- wdman::selenium(jvmargs = c("-Dwebdriver.chrome.verboseLogging=true"), retcommand = TRUE)
shell(selCommand, wait = FALSE, minimized = TRUE)
remDr <- remoteDriver(port = 4567L, browserName = "chrome")
Sys.sleep(5)
remDr$open()
Sys.sleep(5)
# define and navigate to url
url <-"https://www.screener.in/company/HCLTECH/consolidated/"
remDr$navigate(url)
# click the plus buttons
plus_buttons <- remDr$findElements(using = 'css selector',"#cash-flow button.show-schedules.button-link")
for (plus_button in plus_buttons) {
plus_button$clickElement()
}
# print the table
remDr$getPageSource(header = TRUE)[[1]] %>%
read_html() %>%
html_node("#cash-flow .data-table") %>%
html_table()
However, as @hrbrmstr has pointed out, check the terms of the webpage. Check that you are respecting them. In my solution, I'm opting for printing instead of storing so I'm not 'copying' anything from their website.
Hope it helped! If you have any question, just let me know!