Yahoo finance stock data in Google Spreadsheet

Made my first script in Google Spreadsheet

function YahooFinance(ticker) {
var ticker = ticker || "GOOG";
ticker = encodeURI(ticker);
var response = UrlFetchApp.fetch("https://query2.finance.yahoo.com/v7/finance/options/" + ticker);
var chain = JSON.parse(response.getContentText());
return parseFloat(chain.optionChain.result[0].quote.regularMarketPrice);
}

view raw
YahooFinance.js
hosted with ❤ by GitHub

 

In Spreadshhet just click Tools > Script editor to add the script

After saving the script you can call it in the spreadsheet cell

=IF(A2 <> "", YahooFinance(A2), 0)