i need to get the page name of a google sites with google apps script, there is another post about it but is about URL such as Retrieve page title from URL in Apps Script, but i need to get the page title name.
Thanks.
i need to get the page name of a google sites with google apps script, there is another post about it but is about URL such as Retrieve page title from URL in Apps Script, but i need to get the page title name.
Thanks.
If you are in a domain, use the following, replacing teh strings as appropriate.
var site = SitesApp.getSite("mydomainname.org", "sitename");
var page = site.getChildren()[0];
var title = page.getTitle();
Karl
As per this stackoverflow answer, the function works well for getting page title.
function betweenMarkers(text, begin, end) {
var firstChar = text.indexOf(begin) + begin.length;
var lastChar = text.indexOf(end);
var newText = text.substring(firstChar, lastChar);
return newText;
}
var pageTitle = betweenMarkers(response.getContentText(),"<title>","</title>")
console.log(pageTitle)