【问题标题】:Can't access mqlread API无法访问 mqlread API
【发布时间】:2016-05-26 12:25:57
【问题描述】:

我正在尝试从 Freebase 访问 mqlread API,但收到了 "Not Found" 404:

api_key = open("freebaseApiKey").read()
mqlread_url = 'https://www.googleapis.com/freebase/v1/mqlread'
mql_query = '[{"mid": null,"name": null, "type": "/location/statistical_region","limit": 100}]'
cursor = ""

topicService_url = 'https://www.googleapis.com/freebase/v1/topic'
params = {
  'key': api_key,
  'filter': '/location/statistical_region',
  'limit': 0
}

for i in xrange(1000):
    mql_url = mqlread_url + '?query=' + mql_query + "&cursor=" + cursor
    print mql_url
    statisticalRegionsResult = json.loads(urllib.urlopen(mql_url).read())
    ....

显然,当我运行我的 python 文件时,我得到:

https://www.googleapis.com/freebase/v1/mqlread?query=[{"mid": null,"name": null, "type": "/location/statistical_region","limit": 100}]&cursor=
Traceback (most recent call last):
  File "[Filepath]...FreeBaseDownload.py", line 37, in <module>
    statisticalRegionsResult = json.loads(urllib.urlopen(mql_url).read())
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/json/__init__.py", line 307, in loads
    return _default_decoder.decode(s)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/json/decoder.py", line 319, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/json/decoder.py", line 338, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

我在 API 上做错了什么?我已经阅读了有关 mqlread 被弃用的信息,我在 Freebase 中获得所有统计区域(中间)的任务是什么?

【问题讨论】:

    标签: python json freebase


    【解决方案1】:

    一年多前它已被弃用。它终于在 5 月 2 日关闭。

    https://groups.google.com/forum/#!topic/freebase-discuss/WEnyO8f7xOQ

    此信息的唯一来源是 Freebase 数据转储。

    https://developers.google.com/freebase/#freebase-rdf-dumps

    【讨论】:

      猜你喜欢
      • 2021-12-01
      • 2021-03-16
      • 1970-01-01
      • 1970-01-01
      • 2016-02-08
      • 2023-03-09
      • 2019-12-12
      • 2014-01-28
      • 2021-05-26
      相关资源
      最近更新 更多