gpt4 book ai didi

wikipedia-api - 通过 pageId 获取维基百科页面 url

转载 作者:行者123 更新时间:2023-12-05 08:42:59 25 4
gpt4 key购买 nike

我使用 wikipedia api从随机页面中获取摘录。

有示例响应:

{
"batchcomplete": "",
"continue": {
"grncontinue": "0.701350797294|0.701351244349|4312122|0",
"continue": "grncontinue||"
},
"query": {
"pages": {
"1485573": {
"pageid": 1485573,
"ns": 0,
"title": "some title",
"extract": "some text"
}
}
}
}

现在我知道了这个页面的pageid

如何通过pageid获取本页的url

最佳答案

您可以通过添加 info property 从 API 请求它来获取 URL和 inprop=url。它可以与 extracts property 结合使用像这样:prop=info|extracts&inprop=url

例如:

https://en.wikipedia.org/w/api.php?action=query&generator=random&grnnamespace=0&grnlimit=2&prop=info|extracts&inprop=url

{
"continue": {
"excontinue": 1,
"continue": "||info"
},
"query": {
"pages": {
"864588": {
"pageid": 864588,
"ns": 0,
"title": "Benbane Head",
...
"fullurl": "https://en.wikipedia.org/wiki/Benbane_Head",
"editurl": "https://en.wikipedia.org/w/index.php?title=Benbane_Head&action=edit",
"canonicalurl": "https://en.wikipedia.org/wiki/Benbane_Head",
"extract": "<p><span></span></p>\n\n<p><b>Benbane Head</b>, or <b>Benbane</b> (from Irish <i>an Bhinn Bh\u00e1n</i>, meaning \"the white headland\"), is the northernmost point of mainland Northern Ireland. It is in County Antrim, near the Giant's Causeway, which lies between Causeway Head and Benbane Head. The nearest settlements are Bushmills and Portballintrae.</p>\n<h2><span id=\"References\">References</span></h2>\n\n<p><br></p>"
}
}
}

您也可以只在 URL 本身中使用 pageid:https://en.wikipedia.org/?curid=864588

关于wikipedia-api - 通过 pageId 获取维基百科页面 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35323728/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com