On this spreadsheet, the Apps Script returns the right result when I run it, the execution log correctly returns "202000.0".
However, when I run the script in a cell (highlighted in orange on the linked spreadsheet), the cell is empty, does anyone know how to fix this by any chance?
The Apps Script code:
function fullTimeEmployees(url) {
var url = 'https://finance.yahoo.com/quote/WBA/profile'
var source = UrlFetchApp.fetch(url).getContentText()
var jsonString = source.match(/root.App.main = ([\s\S\w]+?);\n/)
if (!jsonString || jsonString.length == 1) return;
var data = JSON.parse(jsonString[1].trim())
Logger.log(data.context.dispatcher.stores.QuoteSummaryStore.assetProfile.fullTimeEmployees)
}
Also, does anyone know what I can change .fulltimeEmployees (at the end) to so it returns the full company name? as pictured here, highlighted in green
However, when I run the script in a cell (highlighted in orange on the linked spreadsheet), the cell is empty, does anyone know how to fix this by any chance?
In your script, no value is returned. This is the reason of your issue. So please modify your script as follows.
function fullTimeEmployees(url) {
var url = 'https://finance.yahoo.com/quote/WBA/profile'
var source = UrlFetchApp.fetch(url).getContentText()
var jsonString = source.match(/root.App.main = ([\s\S\w]+?);\n/)
if (!jsonString || jsonString.length == 1) return;
var data = JSON.parse(jsonString[1].trim())
Logger.log(data.context.dispatcher.stores.QuoteSummaryStore.assetProfile.fullTimeEmployees)
return data.context.dispatcher.stores.QuoteSummaryStore.assetProfile.fullTimeEmployees; // Added
}
Also, does anyone know what I can change .fulltimeEmployees (at the end) to so it returns the full company name? as pictured here, highlighted in green
In this case, how about modifying as follows?
data.context.dispatcher.stores.QuoteSummaryStore.assetProfile.fullTimeEmployees
data.context.dispatcher.stores.QuoteSummaryStore.price.shortName
Walgreens Boots Alliance, Inc.
.