使用 google 个站点 api 检索所有经典和新的 google 站点

Retrieve all classic and new google sites using google sites api

有没有办法检索所有新 google 网站,包括经典网站?我尝试使用 getAllSites(domain, start, max).

// This writes the a list of sites in domain yourdomain.com to the log.
function getNumberOfSites() {
  var pageStart = 0;
  var pageSize = 50;
  while (true) {
    Logger.log("Loading sites starting at %s", pageStart, pageSize);
    var sites = SitesApp.getAllSites("yourdomain.com", pageStart, pageSize);
    // Logger.log(sites);
    if (sites.length == 0) {
      break;
    }
    Logger.log("Got %s sites back", sites.length);
    pageStart += sites.length;
    for(var i in sites) {
      Logger.log("Found site: %s", sites[i].getUrl());
    }
  }
  
}

但我只能检索到具有前缀 /a/ 的经典站点(例如:https://sites.google.com/a/yourdomain.com/demo/). Is there a way I can retrieve both classic and new google sites (which doesn't have a prefix /a/ eg: https://sites.google.com/yourdomain.com/demo/)?

Site Service 只能访问官方文档中所述的经典 Google 站点。

A rebuilt version of Sites was launched on November 22, 2016. Apps Script cannot currently access or modify Sites made with this version, but script can still access classic Sites.


基于此参考:When will available the API Google Site?

Google Sites 的新版本目前不提供 API,但 Google 已宣布 API 功能,包括 Google Apps 脚本集成将可用。

有关详细信息,请参阅 Deprecation Timeline - classic Google Sites

Google doesn't offer dates for when features will be available so you won't find one.