Wikipedia和Wikidata在pageid上不一致

时间:2018-08-20 14:37:18

标签: wikipedia wikidata

寻找Le Havre Libre的页面ID,我查询了Wikidata并得到了以下内容

https://www.wikidata.org/w/api.php?action=wbgetentities&format=json&titles=Le_Havre_libre&sites=enwiki|frwiki&origin=*

{
    "entities": {
        "-1": {
            "site": "enwiki",
            "title": "Le_Havre_libre",
            "missing": ""
        },
        "Q3223483": {
            "pageid": 3077366,
            "ns": 0,
            "title": "Q3223483",
            "lastrevid": 480198576,
            "modified": "2017-04-30T13:53:38Z",
            "type": "item",
            "id": "Q3223483",
            "labels": {
                "fr": {
                    "language": "fr",
                    "value": "Le Havre libre"
                }
            },
            "descriptions": {},
            "aliases": {
                "fr": [
                    {
                        "language": "fr",
                        "value": "Havre Libre"
                    },
                    {
                        "language": "fr",
                        "value": "Le Havre Libre"
                    }
                ]
            },
            "claims": {
                ...
            },
            "sitelinks": {
                "frwiki": {
                    "site": "frwiki",
                    "title": "Le Havre libre",
                    "badges": []
                }
            }
        }
    },
    "success": 1
}

所以我认为pageid应该是3077366

但是https://en.wikipedia.org/?curid=3077366https://fr.wikipedia.org/?curid=3077366都没有到达正确的页面!

从维基百科,我知道实际的pageid1649668

这是怎么回事?

1 个答案:

答案 0 :(得分:4)

这是Wikidata的页面ID:https://www.wikidata.org/?curid=3077366

要获取Wikipedia pageid,您需要在Wikipedia API的查询中使用wikidata API响应中的页面标题和语言:https://fr.wikipedia.org/w/api.php?action=query&titles=Le%20Havre%20libre&format=json

这为您提供了Wikipedia pageid:

  

{“ batchcomplete”:“”,“ query”:{“ pages”:{“ 1649668”:{“ pageid”:1649668,“ ns”:0,“ title”:“ Le Havre libre”}}} }

哪个页面显示正确:https://fr.wikipedia.org/?curid=1649668