【问题标题】:Take data from private google spreadsheet从私人谷歌电子表格中获取数据
【发布时间】:2015-08-20 08:41:56
【问题描述】:
我有一个 Google 电子表格,要与几个人共享。我想构建一个脚本来搜索一些行并获取单元格值,然后在本地处理一个程序。我正在考虑使用 python,因为 Google 似乎为它提供了一个很好的 API。
有关于如何连接到 Google 电子表格的示例吗?我阅读了 api,但我不明白 OAuth 2.0 是如何工作的......
非常感谢:)
【问题讨论】:
标签:
python
google-apps-script
google-sheets
google-spreadsheet-api
【解决方案1】:
要对 Google 电子表格执行读写操作,不需要 OAuth 2.0。如reading 和writing 到 Google 电子表格的这些示例中所示,为了能够访问电子表格,您必须在代码中包含相关帐户的用户名密码。然后按照以下方式使用它们(如写作示例所示)来访问电子表格:
spr_client = gdata.spreadsheet.service.SpreadsheetsService()
spr_client.email = email
spr_client.password = password
spr_client.source = 'Example Spreadsheet Writing Application'
spr_client.ProgrammaticLogin()
另外,请记住import gdata.spreadsheet.service 和您的代码可能需要的任何其他相关库。如果您是新手,this 也是一个不错的起点。希望这会有所帮助!