我需要在 Google docs api in Python ,尽管它是文本,图像,表等。我找不到有关使用Google Docs API的内容类型复制内容的任何参考。有人知道如何实施它吗?
例如,假设我想通过复制和粘贴在Google文档中复制以下内容:
Lorem ipsum dolor sit amet,
[some-image]
[some-table]
consectetur adipiscing elit.
我想具有此输出:
Lorem ipsum dolor sit amet,
[some-image]
[some-table]
consectetur adipiscing elit.
Lorem ipsum dolor sit amet,
[some-image]
[some-table]
consectetur adipiscing elit.
I need to copy all content between an initial and a final index in Google Docs API in Python, despite if it is text, image, table, etc. I couldn't find any reference about copying contents regardless of the content type using Google Docs API. Does anyone know how can I implement it?
For example, suppose I want to duplicate the content below inside a Google Doc by copy and paste:
Lorem ipsum dolor sit amet,
[some-image]
[some-table]
consectetur adipiscing elit.
I want to have this output:
Lorem ipsum dolor sit amet,
[some-image]
[some-table]
consectetur adipiscing elit.
Lorem ipsum dolor sit amet,
[some-image]
[some-table]
consectetur adipiscing elit.
发布评论
评论(1)
我已经使用2个不同的选项来完成此操作:
方法1
复制完整的Google文档,您可以使用 files()。复制驱动器API的方法。类似的内容:
您可以在答案中查看并找到示例代码。 -no-copy-attribute“>此帖子。
注意:您可以使用此方法通过制作文件的完整副本来复制文档的一部分,然后编辑新的副本该文档在保持原始一个未修改的同时。您可以使用 batchupdate 为此
方法2
您可以使用文档.get 在初始索引和最终索引之间获取内容的方法。类似 this :
注意:注意:如果您使用documents.get。文档的原始数据。您将需要搜索“ body”>“ body” 文档。在那里,您将看到文档的内容,其中包括文档的各个首字母和最终索引。之后,您还可以使用 batchupdate 将信息粘贴到新文档或与此情况的同一文档中。
参考:
I have worked with 2 different options to do this:
Method 1
To copy a complete Google Doc, you can use the files().copy method of Drive API. Something like this:
You can review and find a sample code in the answer to this post.
Note: You can use this method to copy a part of the document by making a complete copy of the file, and after that, edit the new copy of the document while keeping the original one unmodified. You can use batchUpdate for that
Method 2
You can use the documents.get method to get the content between an initial and a final index. Something like this:
Note: If you use the documents.get you will get the raw data of the document. You will need to search for the "body" of the document. There you will see the content of the document with the parts of the document with their respective initial and a final index. After that, you can also use a batchUpdate to paste the information into a new document or the same document as on this case.
Reference: