Scrape Yahoo Finance 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 = "" + stockSymbol;
  var response = UrlFetchApp.fetch(url, {muteHttpExceptions: true});
  if (response.getResponseCode()) {
    var html = response.getContentText();
    var title = html.match(/

([^>]+)\(\^?/); if (title) return title[1]; } return stockSymbol; }