Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wikipedia list=search REST API: how to retrieve also Url of matching articles

I'm studying Wikipedia REST API but I'm not able to find the right option to get also URLs for a search query.

this is the URL of the request:

http://it.wikipedia.org/w/api.php?action=query&list=search&srsearch=calvino&format=xml&srprop=snippet

this request outputs only the Title and the Snippet but no URLs for articles. I've checked wikipedia API documentation for the list=search query but seems there is no option to get also URLs.

Best Regards, Fabio Buda

like image 846
Fabio Buda Avatar asked Jan 19 '12 17:01

Fabio Buda


1 Answers

You can form the URL of the article easily by yourself from the title. For the Italian Wikipedia, it's http://it.wikipedia.org/wiki/ followed by the URL-encoded title of the article. It's as simple as that.

The actual URL of the article also replaces spaces with underscores, but you don't have to do that if you don't want to, the URL with spaces redirects to the one with underscores.

EDIT: You can get the URL, but it's not possible to get search-related information at the same time. To do that, use the list as a generator. For example:

http://it.wikipedia.org/w/api.php?action=query&generator=search&gsrsearch=calvino&format=xml&gsrprop=snippet&prop=info&inprop=url

But I think changing the format of page URLs is very unlikely: too many other people rely on that.

like image 154
svick Avatar answered Nov 18 '22 16:11

svick