I'm trying to get an entire table data from https://finance.yahoo.com/quote/CL%3DF/history?p=CL%3DF. On a browser, the webpage shows 1 year data down to Oct 12, 2020 as a default. But the following code didn't pull the whole table data for some reason. It pulled only partial data, just less than 5 month data only down to May 20, 2021. What am I missing? Can anyone help fix anything wrong in the code? Thank you!
function test() {
const url = 'https://finance.yahoo.com/quote/CL%3DF/history?p=CL%3DF';
const res = UrlFetchApp.fetch(url, { muteHttpExceptions: true }).getContentText();
const $ = Cheerio.load(res);
// The URL webpage shows one year data down to Oct 12, 2021 on the browser.
// But the code below got data only down to May 20, 2020. Why am I mssing?
var data = $('table').find('td').toArray().map(x => $(x).text());
console.log(data[data.length-8]); // Print the last row date other than the web note
}