Daron V
Daron V

Reputation: 317

Wikipedia API returns no links for specific articles

I have a query that gets all the links in a Wikipedia article. The problem is that for some pages, it returns no link.

This Wikipedia article has many links on it. However, my query:

http://en.wikipedia.org/w/api.php?titles=Maramures_County&prop=links&plnamespace=0&pllimit=250&format=xml&action=query

Returns only:

<?xml version="1.0"?>
    <api>
        <query>
            <normalized>
                <n to="Maramures County" from="Maramures_County"/>
            </normalized>
            <pages>
                <page title="Maramures County" ns="0" pageid="3625444">
                    <links>
                        <pl title="Maramureș County" ns="0"/>
                    </links>
            </page>
        </pages>
    </query>
</api>

If I run the same query for another article, likes "Moon", I get lots of results.

http://en.wikipedia.org/w/api.php?titles=Moon&prop=links&plnamespace=0&pllimit=250&format=xml&action=query

Returns

<?xml version="1.0"?>
    <api>
        <query-continue>
            <links plcontinue="19331|0|JSTOR"/>
        </query-continue>
        <query>
            <pages>
                <page title="Moon" ns="0" pageid="19331">
                <links>
                    <pl title="3753 Cruithne" ns="0"/>
                    <pl title="51st state" ns="0"/><pl title="Ablation" ns="0"/>

                    [ ... etc, etc  ...]

Am I doing something wrong with the API or is this a bug?

Upvotes: 0

Views: 395

Answers (1)

svick
svick

Reputation: 245028

Actually, the article Maramures County is a redirect to Maramureș County (notice the comma below s), which means it's technically an article with a single link to the redirect target.

To get the links, you can either use the name of the actual article:

http://en.wikipedia.org/w/api.php?titles=Maramure%C8%99%20County&prop=links&plnamespace=0&pllimit=250&format=xml&action=query

Or you can use the redirects parameter:

http://en.wikipedia.org/w/api.php?titles=Maramures%20County&prop=links&plnamespace=0&pllimit=250&format=xml&action=query&redirects

Upvotes: 5

Related Questions