-->

Retrieving multiple articles & images via the new

2019-08-13 12:03发布

问题:

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 ?



标签: api freebase