开发者

What is wikipedia pageid? how to change it into real page url?

开发者 https://www.devze.com 2023-03-08 21:25 出处:网络
I\'m studying the wikipedia API, some demo api call What is the pageid? How do I change it into a real page url?

I'm studying the wikipedia API,

some demo api call

What is the pageid? How do I change it into a real page url?

I mean <page pageid="18630637" ns="0" title="Translation" />, how to change 18630637 into http://en.wikipedia.org/wiki/Tr开发者_高级运维anslation?


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.


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消