Scrape Yahoo Finance for Stock Information with Google Scripts
If you know the the stock symbol like MSFT or GOOG, you can get the full name of the corresponding company by scraping the Yahoo Finance website for that symbol.
function getFundFullName(stockSymbol) {
var url = 'http://finance.yahoo.com/q/hp?s=' + stockSymbol;
var response = UrlFetchApp.fetch(url, { muteHttpExceptions: true });
if (response.getResponseCode()) {
var html = response.getContentText();
var title = html.match(/<h2>([^>]+)\(\^?/);
if (title) return title[1];
}
return stockSymbol;
}
Amit Agarwal
Google Developer Expert, Google Cloud Champion
Amit Agarwal is a Google Developer Expert in Google Workspace and Google Apps Script. He holds an engineering degree in Computer Science (I.I.T.) and is the first professional blogger in India.
Amit has developed several popular Google add-ons including Mail Merge for Gmail and Document Studio. Read more on Lifehacker and YourStory