使用gdata-python-client访问Google图书搜索数据API的SyntaxError

问题描述:

>>> import gdata.books.service
>>> service = gdata.books.service.BookService()
>>> results = service.search_by_keyword(isbn='0434003484')
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
  results = service.search_by_keyword(isbn='0434003484')
... snip ...
File "C:\Python26\lib\site-packages\atom\__init__.py", line 127, in CreateClassFromXMLString
  tree = ElementTree.fromstring(xml_string)
File "<string>", line 85, in XML
SyntaxError: syntax error: line 1, column 0

这是一个最小的示例-特别是,包装中包括的图书服务单元测试也因完全相同的错误而失败.我查看了 Wiki,并在Google Code上打开了发行票证,无济于事(对我而言,这似乎更容易是一个愚蠢的错误,而不是库的问题).我不确定如何解释错误消息.如果重要的话,我使用的是python 2.6.5和最新版本的gdata,即2.0.10.

This is a minimal example -- in particular, the book service unit tests included in the package also fail with the exact same error. I've looked at the wiki and open issue tickets on Google Code to no avail (and this seems to me more apt to be a silly error on my end rather than a problem with the library). I'm not sure how to interpret the error message. If it matters, I'm using python 2.6.5 and the latest version of gdata, namely 2.0.10.

我发现我需要在gdata客户端中禁用SSL才能使其正常工作:

I found I needed to disable SSL in the gdata client for it to work:

...
gd_client.ProgrammaticLogin()
gd_client.ssl = False
...