我正在研究Wikipedia API,
什么是pageid?如何将其更改为真实页面网址?
我的意思是<page pageid="18630637" ns="0" title="Translation" />,如何18630637变成http://en.wikipedia.org/wiki/Translation?
Answers:
该pageid是MediaWiki的内部文章ID。您可以使用动作API的info属性从中获取完整的URL pageid:
https://en.wikipedia.org/w/api.php?action=query&prop=info&pageids=18630637&inprop=url
pageid/title从任何给定的url?
titles参数,而不是:https://en.wikipedia.org/w/api.php?action=query&prop=info&titles=Stack_Overflow
url我们可以得到title还是pageid?
您可以只使用如下网址:
http://en.wikipedia.org/?curid=18630637
这是最短的形式,其他形式也是可能的:
http://en.wikipedia.org/wiki?curid=18630637
http://en.wikipedia.org/wiki/Translation?curid=18630637
http://en.wikipedia.org/w/index.php?curid=18630637
请注意,如果您指定一个curid,MediaWiki将忽略页面标题,因此即使
http://en.wikipedia.org/wiki/FooBar?curid=18630637
指向同一页面。
https://en.wikipedia.org/w/index.php?title=Whistling_hareredirects to https://en.wikipedia.org/wiki/Pika。对于此页面,参数redirect=no存在(https://en.wikipedia.org/w/index.php?title=Whistling_hare&redirect=no)。我希望有一个类似的网址https://en.wikipedia.org/w/index.php?curid=186307&redirect=yes。实际上https://en.wikipedia.org/w/index.php?curid=186307默认情况下重定向到https://en.wikipedia.org/w/index.php?title=Pika&curid=186307
哦,如果您添加“&prop = info&inprop = url”,您也可以在初始API调用中获得完整页面的URL: