0

In a Flask app, or even better just using wikipedia APIs, how can I get the pageid from a Wikipedia url?

I mean from this http://en.wikipedia.org/wiki/Stack_Overflow to this http://en.wikipedia.org/wiki?curid=21721040

From the API sandbox I can work it out but only as a search from a title, not from a singular URL.

Said search example: https://en.wikipedia.org/wiki/Special:ApiSandbox#action=query&prop=pageprops&format=json&ppprop=wikibase_item&titles=Stack%20Overflow

Can I query for it in a more straightforward way and without resorting to a wikipedia search? I mean I already know the human readable url...

4

1 回答 1

6

不,您不能在 API 中使用 URL,您需要使用页面名称或页面 ID 来识别文章。

请注意,您找到的https://en.wikipedia.org/w/api.php?action=query&titles=Stack%20Overflow不是“搜索”,它只是从标题中获取页面 ID 的查询。用它。

于 2015-03-17T16:55:32.947 回答