什么是维基百科 pageid? 如何将其转换为真正的 page url?

我在研究维基百科 API,

一些演示应用程序接入

什么是网页页面? 我如何改变它成一个真正的网页网址?

我的意思是 <page pageid="18630637" ns="0" title="Translation" />,如何把 18630637变成 http://en.wikipedia.org/wiki/Translation

62715 次浏览

The pageid is the MediaWiki's internal article ID. You can use the action API's info property to get the full URL from pageid:

https://en.wikipedia.org/w/api.php?action=query&prop=info&pageids=18630637&inprop=url

You can just use a URL like this:

http://en.wikipedia.org/?curid=18630637

This is the shortest form, others are also possible:

http://en.wikipedia.org/wiki?curid=18630637

http://en.wikipedia.org/wiki/Translation?curid=18630637

http://en.wikipedia.org/w/index.php?curid=18630637

Note that MediaWiki ignores the page title if you specify a curid, so even

http://en.wikipedia.org/wiki/FooBar?curid=18630637

leads to the same page.

Oh, and you can also get the full page URL in your initial API call if you add "&prop=info&inprop=url":

http://en.wikipedia.org/w/api.php?action=query&generator=search&gsrsearch=meaning&srprop=size%7Cwordcount%7Ctimestamp%7Csnippet&prop=info&inprop=url