I am hoping to update a script to a Google Apps Script project that will provide me with the word count for an inputted website.
I have some code that helps me get this for a google doc but not quite a website. I would prefer to run the function in relation to a URL input in a cell and get the word count of that URL.
Here is the code for the doc.
function wordCount() {
var space = " ";
var text = DocumentApp.getActiveDocument().getBody().getText();
var words = text.replace(/s+/g, space).split(space);
Logger.log(words.length);
}
Additionally I would really like a way to get the count of occurrences a single word shows on a webpage.
So in summation, my hope is that when I have a sheet that includes an "https://www.example.com" in cell A2, I would be able to run the following:
=wordCount(A2) - results in the word count for the URL
=keywordCount(A2,"keyword") - results in the count of "keyword" occurrences on "https://www.example.com"
Thanks in advance!
question from:
https://stackoverflow.com/questions/66066329/webpage-word-keyword-count-google-apps-script 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…