python - python 的 gdata 电子表格库不再工作了?

标签 python google-sheets gdata

我试图在我的一个谷歌文档中运行数据查询,它已经工作了几个月。从昨天或前一天开始,我发现我的脚本不再有效。 Google 是否更新了电子表格的 API?有人找到解决方法了吗?

我的错误是这样的:

Traceback (most recent call last):
  File "build_packer_image.py", line 311, in <module>
    for index, entry in enumerate(client.GetWorksheetsFeed(doc_key).entry):
  File "/build/toolchain/mac-10.5-32/lib/python2.7/site-packages/gdata/spreadsheet/service.py", line 129, in GetWorksheetsFeed
    converter=gdata.spreadsheet.SpreadsheetsWorksheetsFeedFromString)
  File "/build/toolchain/mac-10.5-32/lib/python2.7/site-packages/gdata/service.py", line 1074, in Get
    return converter(result_body)
  File "/build/toolchain/mac-10.5-32/lib/python2.7/site-packages/gdata/spreadsheet/__init__.py", line 411, in SpreadsheetsWorksheetsFeedFromString
    xml_string)
  File "/build/toolchain/mac-10.5-32/lib/python2.7/site-packages/atom/__init__.py", line 93, in optional_warn_function
    return f(*args, **kwargs)
  File "/build/toolchain/mac-10.5-32/lib/python2.7/site-packages/atom/__init__.py", line 127, in CreateClassFromXMLString
    tree = ElementTree.fromstring(xml_string.replace('doctype','DOCTYPE'))
  File "<string>", line 125, in XML
cElementTree.ParseError: no element found: line 1, column 0
Build step 'Execute shell' marked build as failure
Finished: FAILURE

我正在使用:

  • python 2.7.5
  • gdata 2.0.18

我只是在我的代码中使用了一个文档 key 而没有使用 oauth,如果这会有所不同(我将用户名和密码传递给 ClientLogin 方法)

最佳答案

其实这里就是问题的答案:

The use of client login (using username/password instead of oauth2) is likely the cause of the error. That protocol was deprecated 3+ years ago and was just shutdown. If you capture the HTTP response (which appears to have some HTML content), that might confirm if it is related to the shutdown. Migrating to OAuth 2 would get your apps working again.

在电子表格中发送用于更新的 xml 后,谷歌会返回一个登录页面。 这意味着身份验证现在不适用于 gdata

https://code.google.com/a/google.com/p/apps-api-issues/issues/detail?id=3851#c2

关于python - python 的 gdata 电子表格库不再工作了?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30492589/

相关文章:

python - 如何在 python 中创建一个股票报价获取应用程序

python - skcuda linalg 中的 "unsupported combination of input order"

javascript - 以编程方式向 Google Apps 脚本中的加载项添加基于时间的触发器

php - 获取特定 Google 日历的 Zend_GData 提要

dotnetopenauth - 如何使用 DotNetOpenAuth 登录 Google 并获取用户资料

java - 使用 Docs api JAVA 检索文本文档内容

python - : python string assignments accidentally change '\b' into '\x08' and '\a' into '\x07' , 为什么 Python 这样做?

Python,我想制作列表 json.dumped 但是,错误 'dict' 对象没有属性 'dumps'

google-sheets - Google 表格 - 来自其他表格的条件格式

google-sheets - 显示空白值的总和