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.
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.