Retrieving the Interlanguage links from an exported Wikipedia article?
Asked Answered
S

2

6

I used to retrieve the interlanguage links from an exported Wikipedia article by parsing the export with some regular expressions.

In phase 1 of the WikiData project these links have been moved to a separate page on Wikidata.

For example the article Ore Mountains has no language links anymore in the export. The language links are now on Q4198.

How can I export the language links?

Samothrace answered 18/5, 2013 at 23:8 Comment(1)
Asimov, if an answer unlocked your situation please validate it. (if it's mine it will be my first validated answer)Reckoner
S
1

I changed from using the export to the API. You can retrieve the interwikilanguage links with the property "langlinks", like this:

http://en.wikipedia.org/w/api.php?action=query&titles=Ore%20Mountains&prop=langlinks

Samothrace answered 19/5, 2013 at 10:44 Comment(3)
As far as I understand it, this will stop working soon, and some time after that, it will start working again if you add a parameter to the query.Catlin
That will keep working, but as the Wikidata is moving forward, all interwiki data will be removed from wikipedia, and moved to wikidata. Phase 1 should already had remove most of them from wikipedia.Reckoner
Using the api as shown in the answer retrieves the correct links. As the interwiki links from the page in the question are already moved to wikidata, I suppose that this is the correct way to get the links.Samothrace
R
5

You are now encouraged to use the Wikidata aPI : http://wikidata.org/w/api.php

For your case, use props=labels. This url is self explicative :

http://www.wikidata.org/w/api.php?action=wbgetentities&sites=enwiki&titles=Ore%20Mountains&languages=cs|de|es|fr|it|pl|pt|ru&props=labels&format=xml
Reckoner answered 20/5, 2013 at 10:53 Comment(2)
this works, but for some languages I get a result even if the article does not exist on wikipedia. Is there a way to solve this issue?Josefina
the fact is that the wikipedia links are sitelinks, not labels. for example try your url with "Giancarlo Magalli" instead of "Ore Mountains" you will have many languages even if it is available only in italianJosefina
S
1

I changed from using the export to the API. You can retrieve the interwikilanguage links with the property "langlinks", like this:

http://en.wikipedia.org/w/api.php?action=query&titles=Ore%20Mountains&prop=langlinks

Samothrace answered 19/5, 2013 at 10:44 Comment(3)
As far as I understand it, this will stop working soon, and some time after that, it will start working again if you add a parameter to the query.Catlin
That will keep working, but as the Wikidata is moving forward, all interwiki data will be removed from wikipedia, and moved to wikidata. Phase 1 should already had remove most of them from wikipedia.Reckoner
Using the api as shown in the answer retrieves the correct links. As the interwiki links from the page in the question are already moved to wikidata, I suppose that this is the correct way to get the links.Samothrace

© 2022 - 2024 — McMap. All rights reserved.