3

我有一个脚本可以读取 Freebase 数据,但它突然停止工作。它输出以下错误:

AttributeError: 'Resource' object has no attribute 'mqlread'

所以我尝试了谷歌文档中的示例代码,

from apiclient import discovery
from apiclient import model
import json

DEVELOPER_KEY = 'my_key'

model.JsonModel.alt_param = ""
freebase = discovery.build('freebase', 'v1', developerKey=DEVELOPER_KEY)
query = [{'id': None, 'name': None, 'type': '/film/film'}]

def do_query(cursor=""):

    response = json.loads(freebase.mqlread(query=json.dumps(query), cursor=cursor).execute())
    for item in response['result']:
        print item['name']

    return response.get("cursor")

cursor = do_query()
while(cursor):
    cursor = do_query(cursor)

我得到了同样的错误...... mqlread 方法已经消失,当我这样做时,我也dir(freebase)得到了这个:

['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__getstate__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_add_basic_methods', '_add_nested_resources', '_add_next_methods', '_baseUrl', '_developerKey', '_dynamic_attrs', '_http', '_model', '_requestBuilder', '_resourceDesc', '_rootDesc', '_schema', '_set_dynamic_attr', '_set_service_methods', u'reconcile', u'search', u'search_media']

他们是否在新版本的 API 客户端中删除了此功能?我正在使用 1.2 版的 google-api-python-client

4

2 回答 2

3

对于那个很抱歉。这是 mqlread 服务在 Google API Discovery 服务中不可见的临时问题。API 本身仍可从https://www.googleapis.com/freebase/v1/mqlread访问,但谷歌客户端库依赖于发现服务将 mqlread 作为方法公开。我们的工程团队正在努力修复,应该很快就会推出一些东西。当他们这样做时,我会更新这个。

于 2013-10-17T21:49:32.940 回答
0

It seems that mql-related APIs are the old APIs and are not well supported by Google. So I would suggest you to use freebase.search() instead, which can finish almost all the things that freebase.mqlread() can do.

于 2014-11-25T23:57:29.620 回答