2013-05-16 41 views
0

我有一個查詢可獲取維基百科文章中的所有鏈接。問題在於,對於某些頁面,它不返回任何鏈接。Wikipedia API不返回任何特定文章的鏈接

這個Wikipedia article有很多鏈接。 然而,我的查詢:

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

僅返回:

<?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> 

如果我運行相同的查詢另一篇文章,喜歡 「月亮」,我得到很多結果。

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

返回

<?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 ...] 

我做得不對的API或者這是一個錯誤?

回答

5

實際上,文章Maramures County是一個重定向到Maramureș County(注意下面的逗號s),這意味着它在技術上是an article with a single link to the redirect target

要獲得鏈接,您可以使用實際物品的名稱:

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

或者你可以使用redirects參數:

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