Wikipedia runs on MediaWiki (plus some customizations which are also available), so the answer to your first question is "Yes".
First you need to use the OpenSearch API to find which pages contain the information you want. Searching for o2 arena london
is the following URL:
https://en.wikipedia.org/w/api.php?action=opensearch&search=o2+arena+london&format=jsonfm
which gives the following results:
[
"o2 arena london",
[
"O2 Arena London"
]
]
Using these results we can ask Wikipedia to return the HTML of the page. Here, the page "O2 Arena London" is a redirect to "O2 Arena (London)", so we need to ask Wikipedia to resolve the redirects and give us the final page. This is done using action=parse
:
https://en.wikipedia.org/w/api.php?action=parse&redirects=1&page=O2+Arena+London&format=jsonfm
Which gives the following (shortened) results:
{
"parse": {
"title": "The O2 Arena",
"revid": 578231031,
"redirects": [
{
"from": "O2 Arena London",
"to": "The O2 Arena"
}
],
"text": {
"*": "<div class=\"dablink\">This article is about the indoor arena located in
London. For other uses, see <a href=\"/wiki/O2_Arena_(disambiguation)\"
title=\"O2 Arena (disambiguation)\" class=\"mw-redirect\">O2 Arena</a>.
...
You can display the result, but it may look weird without the CSS styling of Wikipedia.
Note, also, that if you want actual JSON, you would use format=json
instead of format=jsonfm
.