A simple client to query wikipedia
wikipedia-js is a simple client that enables you to query Wikipedia articles in english. The results are formatted in basic HTML. Presently, wikipedia-js only works if you request a summary of an article (i.e. everything before the table of contents on a Wikipedia page). Work is currently in progress to format a whole Wikipedia article page.
This project was created because Wikipedia do currently not support a node.js API.
$ npm install wikipedia-js
All searches are performed via the single method searchArticles:
var wikiParser = require"wikiParser";var query = "Napoleon Bonaparte";var options = query: query format: "json" summaryOnly: true;wikiClientsearchArticleoptionsiferrconsole.log"An error occurred[query=%s, error=%s]" query err;elseconsole.log"Query successful[query=%s, html-formatted-wiki-text=%s]" query htmlWikiText;/*You should see something along the lines of:<p><strong>Napoleon Bonaparte</strong> (French: Napoléon Bonaparte [napoleɔ̃ bɔnɑpaʁt], Italian: Napoleone Buonaparte; 15 August 1769 – 5 May 1821) was a French military and political leader who rose to prominence during the latter stages of the <a href=">French Revolution</a> and its associated <a href=">wars</a> in Europe.</p><p>As <strong>Napoleon I</strong>, he was <a href=">Emperor of the French</a> from 1804 to 1815. His legal reform, the <a href=">Napoleonic Code</a>, has been a major influence on many <a href=(legal_system)">civil law</a> jurisdictions worldwide, but he is best remembered for his role in the wars led against France by a series of coalitions, the so-called <a href=">Napoleonic Wars</a>. He established hegemony over most of continental Europe and sought to spread the ideals of the French Revolution, while consolidating an <a href=">imperial monarchy</a> which restored aspects of the deposed <em><a href=">Ancien Régime</a>.</em> Due to his success in these wars, often against numerically superior enemies, he is generally regarded as one of the greatest military commanders of all time, and his campaigns are studied at military academies worldwide.(ref: Schom 1998)</p><p>Napoleon was born at <a href=">Ajaccio</a> in <a href=">Corsica</a> in a family of <a href=">noble Italian</a> ancestry which had settled Corsica in the 16th century. He trained as an artillery officer in mainland France. He rose to prominence under the <a href=">French First Republic</a> and led successful campaigns against the <a href=">First</a> and <a href=">Second</a> Coalitions arrayed against France. He led a successful invasion of the Italian peninsula.</p><p>In 1799, he staged a <em><a href=">coup d</em>état</a> and installed himself as <a href=">First Consul</a>; five years later the French Senate proclaimed him emperor, following a <a href=">plebiscite</a> in his favour. In the first decade of the 19th century, the <a href=">French Empire</a> under Napoleon engaged in a series of conflicts—the Napoleonic Wars—that involved every major European power.(ref: Schom 1998) After a streak of victories, France secured a dominant position in continental Europe, and Napoleon maintained the French <a href=">sphere of influence</a> through the formation of extensive alliances and the appointment of friends and family members to rule other European countries as French <a href=">client state</a>s.</p><p>The <a href=">Peninsular War</a> and 1812 <a href=">French invasion of Russia</a> marked turning points in Napoleons fortunes. His <a href=">Grande Armée</a> was badly damaged in the campaign and never fully recovered. In 1813, the <a href=">Sixth Coalition</a> defeated his forces <a href=">at Leipzig</a>; the following year the Coalition invaded France, forced Napoleon to abdicate and exiled him to the island of <a href=">Elba</a>. Less than a year later, he escaped Elba and returned to power, but was defeated at the <a href=">Battle of Waterloo</a> in June 1815. Napoleon spent the last six years of his life in confinement by the British on the island of <a href=">Saint Helena</a>. An autopsy concluded he died of <a href=">stomach cancer</a>, but there has been some debate about the cause of his death, as some scholars have speculated that he was a victim of <a href=">arsenic poisoning</a>.</p>*/;
The following features will be added soon:
(The MIT License)
Copyright (c) 2013 Kenshiro <firstname.lastname@example.org>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.