Created
September 30, 2017 12:31
-
-
Save Prakhar0409/af839bf3f9fadfaa56950a67bf56855d to your computer and use it in GitHub Desktop.
A quick description of how any wikipedia can be searched for some query and retrieve result in HTML using NodeJs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var wikipedia = require("wikipedia-js"); // using wikipedia-js library for search | |
var options = {query: query, format: "html", summaryOnly: false, lang: "en"}; | |
wikipedia.searchArticle(options, function(err, htmlWikiText){ // searching wikipedia with options | |
if(err){ | |
console.log("An error occurred[query=%s, error=%s]", query, err); | |
return; | |
} | |
callback('<div style="text-align: justify !important;">'+htmlWikiText+'</div>'); // Pretty print the wiki-html-text | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment