I am new with Google Sheets Script Editor. I am trying to get a function that returns how many time a word (in this case Mother) is present in a Bing website search. So I try this code:
function myFunction112() {
const url = "https://www.bing.com/search?q=“Not all of us can do great things. But we can do small things with great love.”";
const html = UrlFetchApp.fetch(url).getContentText();
const numberOfOcurrencies = (html.match(/Mother/g) || []).length;
console.log(numberOfOcurrencies);
return numberOfOcurrencies;
}
The problem is that in Console it shows 18 for numberOfOcurrencies that is correct, but in my google sheet return 0. As you can see in the images below.
Script editor
Google sheet
I call my function myFunction112 to make sure no other function has the same name.
How can I make my function return the same value that shows in console?
Many thanks.
question from:
https://stackoverflow.com/questions/65852470/google-sheets-function-in-script-editor-return-different-value-in-google-sheets 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…