无法访问mqlread API

时间:2016-05-26 12:25:57

标签: python json freebase

我正在尝试从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中获取所有统计区域(中间)的要求是什么?

1 个答案:

答案 0 :(得分:2)

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

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

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

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