use*_*793 5 python gdata-api google-docs-api
使用Google Document API,我正在尝试创建新文档,并在我的Google文档中提供特定文件夹中所有当前文档的列表.我开始使用python开发,所以我仍然有点粗糙.
我想做的事情:
我相信我正在使用Google Docs API 3.0并且正在使用gdata-2.0.16 helper for python.
代码到目前为止:
import gdata.docs.data
import gdata.docs.client
class SampleConfig(object):
APP_NAME = 'GDataDocumentsListAPISample-v1.0'
DEBUG = False
client = gdata.docs.client.DocsClient()
client.ClientLogin('[email_address]','[password]',source=SampleConfig.APP_NAME )
col = gdata.docs.data.Resource(type='folder', title='Folder Name')
col = client.CreateResource(col)
doc = gdata.docs.data.Resource(type='document', title='I did this')
doc = client.CreateResource(doc, collection=col)
所以现在回答问题:我无可救药地陷入困境:
我知道我离这里已经很远了,但是你能提供的任何帮助或建议都会很棒.
提前致谢!
您可以查询文件夹或文档。获得文件夹后,您可以列出其内容。下面是一个使用 Python 库的示例:
# Create a query matching exactly a title, and include collections
q = gdata.docs.client.DocsQuery(
title='EFD',
title_exact='true',
show_collections='true'
)
# Execute the query and get the first entry (if there are name clashes with
# other folders or files, you will have to handle this).
folder = client.GetResources(q=q).entry[0]
# Get the resources in the folder
contents = client.GetResources(uri=folder.content.src)
# Print out the title and the absolute link
for entry in contents.entry:
print entry.title.text, entry.GetSelfLink().href
Run Code Online (Sandbox Code Playgroud)
输出
My posted doc https://docs.google.com/...
subtestcoll2 https://docs.google.com/...
guestimates_1 https://docs.google.com/...
phase 2 delivery plan - draft https://docs.google.com/...
Meeting agenda June 09 https://docs.google.com/...
Phase 2 spec for Graeme 2 March 2009 https://docs.google.com/...
EFD Meeting 2nd June https://docs.google.com/...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3377 次 |
| 最近记录: |