We all love Wikipedia. I wish I had had Wikipedia when I was growing up; it would have made my life much easier. I had to use an old thing named a book, or an encyclopedia, to research my tasks for school. Just shows how the Internet has evolved. Just shows how lazy people has become… It is just my opinion.
The funny thing is: I am using Wikipedia to find a proper explanation for Wikipedia—for the uninformed, of course… Wikipedia states the following about Wikipedia:
Wikipedia is a multilingual, Web-based, free-content encyclopedia project supported by the Wikimedia Foundation and based on a model of openly editable content. The name “Wikipedia” is a portmanteau of the words wiki (a technology for creating collaborative Web sites, from the Hawaiian word wiki, meaning “quick”) and encyclopedia. Wikipedia’s articles provide links designed to guide the user to related pages with additional information.
Wikipedia is written collaboratively by largely anonymous volunteers who write without pay. Anyone with Internet access can write and make changes to Wikipedia articles, except in limited cases where editing is restricted to prevent disruption or vandalism. Users can contribute anonymously, under a pseudonym, or, if they choose to, with their real identity.
The Good News!
As with many a known decent online platform, Wikipedia is also built with certain APIs and provides developers with these APIs to make use of their product in the background on your own custom made applications.
This platform is named MediaWiki, which is a free and open-source wiki application. MediaWiki has an extensible Web API (application programming interface) that provides direct, high-level access to the data contained in the MediaWiki databases.
Options Available to Developers
Unfortunately, there aren’t many options available for Visual Basic developers, as is usually the case when it comes to Web platforms. This has always baffled me….
The MediaWiki documentation, as well as links, can be found at this link (MediaWiki). As you can see, this is mostly for Web-based platforms such as JSON, XML, and PHP. Still, there is a lot of useful information on how this API works and how Wikipedia makes use of it in the background.
Other options include the following:
- WikiAccess Library: WikiAccess is a library that provides access to MediaWiki-based wiki sites
- DotNetWikiBot Framework: Is a full-featured client API, that allows you to build programs and Web robots easily to manage information on MediaWiki-powered sites.
Let’s do a project!
Create a new Visual Basic Console Application project. Set a Reference to the DotNetWikiBot DLL you get after you have downloaded the framework at the link given earlier.
Import the DotNetWikiBot Namespace:
Make sure your class derives from Bot:
Public Class BotTest Inherits Bot
Adding a Category and Saving It
Add the following code to add a new Wikipedia sub category and save a simple comment:
Dim stWiki As New Site("http://en.wikipedia.org", _ "Login", "Password") Dim pPage As New Page(stWiki, "Music") pPage.Load() pPage.AddToCategory("Afrikaans") pPage.Save("comment: category link added", True)
Saving Wikipedia Files
Add the following code:
Dim plWiki As New PageList(stWiki) plWiki.FillFromGoogleSearchResults("South Africa", 100)
plWiki.FillFromCategoryTree("South Africa") pl.SaveToFiles("C:Hannes")
For more a complete list of all available methods and types of DotNetWikiBot, its Help page is quite thorough.
Gaining access to what makes Wikipedia tick is very easy with the MediaWiki API. Until next time, have a good night.