Jason Hee
Sep 9, 2022

--

Hey Vipaeri, thanks for highlighting this. It's a bug with the regex used to parse the web page's content. Try this new function:

function yahooF(ticker) {

const url = `https://finance.yahoo.com/quote/${ticker}?p=${ticker}`;

const res = UrlFetchApp.fetch(url, {muteHttpExceptions: true});

const contentText = res.getContentText();

const price = contentText.match(/<fin-streamer(?:.*?)data-test="qsp-price"(?:.*)>(\d+[,]?[\d\.]+)(?:.*)<\/fin-streamer>/);

return price[1];

}

--

--

Jason Hee
Jason Hee

Written by Jason Hee

I’m a software engineer who loves tech

Responses (1)