Retrieving multiple articles & images via the new Freebase API

爷,独闯天下 提交于 2020-01-06 03:54:11

问题


I want to get the article text & images for a bunch of topics from freebase. Using the old API this was easy, via either MQL extensions or the topic API (also now deprecated?). But what is now the best way of doing this via the new API?

I see from the docs I can get the text for an individual topic, like this:

https://www.googleapis.com/freebase/v1/text/en/bob_dylan

So I could loop through each topic one by one, but it seems slow to have to hit the API so many times, especially when I only needed one before. Am I missing some clever way of retrieving text / images for multiple topics?

Cheers,

Ben


回答1:


It is possible to do multiple calls for /text using JSON-RPC - http://en.wikipedia.org/wiki/JSON-RPC

Here's an example: curl "https://www.googleapis.com/rpc" -d "[{'method': 'freebase.text.get', 'apiVersion': 'v1', 'params': {'id': ['en','bob_dylan']}},{'method': 'freebase.text.get', 'apiVersion': 'v1', 'params': {'id': ['en','blade_runner']}}]" -H "Content-Type: application/json"

We are working on improving our documentation for doing this but this should get you going.

The name of the method you want to call is freebase.text.get and the rest of the parameters are documented here: http://wiki.freebase.com/wiki/ApiText#Parameters You can pass the id using an "id" parameter.

What exactly are you looking for for images ? How would you get back multiple binary content ?



来源:https://stackoverflow.com/questions/9099416/retrieving-multiple-articles-images-via-the-new-freebase-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!