Skip to content

Instantly share code, notes, and snippets.

@Prakhar0409
Created September 30, 2017 12:31
Show Gist options
  • Save Prakhar0409/af839bf3f9fadfaa56950a67bf56855d to your computer and use it in GitHub Desktop.
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
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