How to get the Infobox data from Wikipedia?

Use the Mediawiki API through this Python library: https://github.com/siznax/wptools

Usage:

import wptools
so = wptools.page('Stack Overflow').get_parse()
infobox = so.data['infobox']
print(infobox)

Output:

{'alexa': '{{Increase}} 34 ( {{as of|2019|12|15|lc|=|y}} )',
 'author': '[[Jeff Atwood]] and [[Joel Spolsky]]',
 'caption': 'Screenshot of Stack Overflow in February 2017',
 'commercial': 'Yes',
 'content_license': '[[Creative Commons license|CC-BY-SA]] 4.0',
 'current_status': 'Online',
 'language': 'English, Spanish, Russian, Portuguese, and Japanese',
 'launch_date': '{{start date and age|2008|9|15}}',
 'logo': 'Stack Overflow logo.svg',
 'name': 'Stack Overflow',
 'owner': '[[Stack Exchange]], Inc.',
 'programming_language': '[[C Sharp (programming language)|C#]]',
 'registration': 'Optional',
 'screenshot': 'File:Stack Overflow homepage, Feb 2017.png',
 'type': '[[Knowledge market]]',
 'url': '{{URL|https://stackoverflow.com}}'}

If you just want to parse the infobox or you want to get some digested data, a look at the DBPedia project: http://dbpedia.org

The DBPedia project scans the infoboxes in WP to create a RDF database from Wikipedia: https://github.com/dbpedia/extraction-framework/


There is no trivial way to do that. You can try fetching the page content using action=raw, i.e. http://en.wikipedia.org/w/index.php?action=raw&title=Douglas_Jardine Then find the start of the infobox by searching for {{Infobox. Then find the end by finding the matching }}, taking into account that the infobox itself can also contain {{-}} and {{{-}}} pairs.


Each Wikipedia page is associated with a Wikidata item, and all these items include the most parameters from the Wikipedia page's Infobox templates. So you need only to access the data associated with your Wikipedia page from Wikidata API.

An example of how to get the data for Wikipedia Donald Trump page from Wikidata item:

https://www.wikidata.org/w/api.php?action=wbgetentities&sites=enwiki&props=claims&titles=Donald Trump

The response will include: date and place of birth, image, religion, mother, father, children, height, signature, official website, etc..., all main info about Donald Trump included in the Wikipedia Infobox...


Tomxu - what you're talking about is a template - which is simple a page you can include on another page. For the infobox you need to start by looking at Template:Infobox. This gives you detailed instructions.

You can also press edit (or view code) and copy the contents to your own wiki. Bear in mind that templates tend to be in a hierarchy so you might need to copy other templates that Infobox uses (if you want to use them). Each template can be identified with {{}} so e.g. the Infobox template will look like this: {{Infobox}}.

I mentioned a hierarchy: you'll actually find multiple templates that all use Template: Infobox. To find them, just type this into Wikipedia's search field: Template:Infobox and then you'll find multiple examples, e.g. Template:Infobox writer

Update: if you mean Navboxes, then see this information.