有没有办法从应用程序脚本访问Google文档摘要?

发布于 2025-01-17 14:10:58 字数 400 浏览 4 评论 0 原文

2022年3月,Google宣布,以及文档概述。我想知道是否有一种方法可以访问这些加油中的这些摘要,例如 DocumentApp

In March 2022, Google announced autogenerated summaries for some documents, alongside the document outline. I'm wondering if there's a way to access these summaries in gas, e.g. via DocumentApp.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

星星的轨迹 2025-01-24 14:10:58

从Google文档获取摘要文本:

在当前阶段,为了检索文档摘要,您可以使用Drive API检索它,如下所示。

GET https://www.googleapis.com/drive/v3/files/fileId?fields=description

Google Apps 脚本示例如下。使用此功能时,请在高级 Google 服务中启用 Drive API。

const documentId = "###"; // Please set Document ID.
const summary = Drive.Files.get(documentId).description;
console.log(summary)
  • 运行此脚本时,可以检索 Google 文档的摘要文本。

  • 在这种情况下,您还可以按如下方式使用云端硬盘服务(DriveApp)。

     const documentId = "###"; // 请设置文档ID。
      const 摘要 = DriveApp.getFileById(documentId).getDescription();
      控制台.log(摘要)
    

将摘要文本设置为 Google 文档:

为了检索文档摘要,您可以使用 Drive API 将其放入,如下所示。

PATCH https://www.googleapis.com/drive/v3/files/fileId

content-type: application/json

{"description": "sample summary text"}

Google Apps 脚本示例如下。使用此功能时,请在高级 Google 服务中启用 Drive API。

const documentId = "###"; // Please set Document ID.
const summary = "sample summary";
Drive.Files.patch({description: summary}, documentId);
  • 运行此脚本时,可以将摘要文本放入 Google 文档。

  • 在这种情况下,您还可以按如下方式使用云端硬盘服务(DriveApp)。

     const documentId = "###"; // 请设置文档ID。
      const 摘要 =“示例摘要”;
      DriveApp.getFileById(documentId).setDescription(summary);
    

注意:

  • 不幸的是,在当前阶段,我无法测试这些脚本以获取文档中自动生成的摘要。但是,我猜想可以通过此方法检索自动生成的摘要。

参考文献:

Get summary text from Google Document:

In the current stage, in order to retrieve the document summary, you can retrieve it using Drive API as follows.

GET https://www.googleapis.com/drive/v3/files/fileId?fields=description

The sample Google Apps Script is as follows. When you use this, please enable Drive API at Advanced Google services.

const documentId = "###"; // Please set Document ID.
const summary = Drive.Files.get(documentId).description;
console.log(summary)
  • When this script is run, the summary text of Google Document can be retrieved.

  • In this case, you can also use Drive service (DriveApp) as follows.

      const documentId = "###"; // Please set Document ID.
      const summary = DriveApp.getFileById(documentId).getDescription();
      console.log(summary)
    

Set summary text to Google Document:

In order to retrieve the document summary, you can put it using Drive API as follows.

PATCH https://www.googleapis.com/drive/v3/files/fileId

content-type: application/json

{"description": "sample summary text"}

The sample Google Apps Script is as follows. When you use this, please enable Drive API at Advanced Google services.

const documentId = "###"; // Please set Document ID.
const summary = "sample summary";
Drive.Files.patch({description: summary}, documentId);
  • When this script is run, the summary text can be put to Google Document.

  • In this case, you can also use Drive service (DriveApp) as follows.

      const documentId = "###"; // Please set Document ID.
      const summary = "sample summary";
      DriveApp.getFileById(documentId).setDescription(summary);
    

Note:

  • Unfortunately, in the current stage, I cannot test these scripts for the autogenerated summary in Document. But, I guess that the autogenerated summary might be able to be retrieved by this method.

References:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文