A Simple API for DenoJS to Query Wikipedia and Parse The Results

A Simple API for DenoJS to Query Wikipedia and Parse The Results

DenoWiki A simple API for DenoJS to query Wikipedia and parse the results.

DenoWiki

A simple API for DenoJS to query Wikipedia and parse the results.

Usage

import * as wiki from "https://deno.land/x/denowiki/mod.ts";

const wikiSearchResult: wiki.WikiSearch_Query = await wiki.wikiSearch(
  { language: "en", srsearch: "doctor who", srlimit: 15 },
);
const pageID: number = wiki.getPageId(wikiSearchResult);
const wikiPage: wiki.WikiParse_Query = await wiki.wikiParse(
    { pageid: pageID, language: "en", prop: "wikitext|text" },
  );
const text: string = wiki.getWikiText(wikiPage);

console.log(text);

This module use the Wikipedia API:Search and API:Parsing wikitext.

Require deno (obviously) and --allow-net permission.

There are 2 demos available. The first demo queries Wikipedia and print the first result

deno run --allow-net .\demo_cmd.ts milan en false
deno run --allow-net .\demo_cmd.ts "doctor who" en true

The second demo searches a list of people and return how many exist in Wikipedia

deno run --allow-net .\demo_array.ts

You can run the demos directly from the repository with the commands:

deno run --allow-net https://deno.land/x/denowiki/demo_cmd.ts milan en false
deno run --allow-net https://deno.land/x/denowiki/demo_cmd.ts "doctor who" en true
deno run --allow-net https://raw.githubusercontent.com/el3um4s/DenoWiki/master/demo_array.ts

API: wikiSearch

  • function wikiSearch(options): Promise : Search for a term on Wikipedia and return the corresponding pages (max 500)
  • function getPageId(wikiJSON: WikiSearch_Query, position): number : Returns the pageID number of Wikipedia referring to the searched term
  • function getSearchTitle(wikiJSON: WikiSearch_Query, position): string : Returns the Title of Wikipedia referring to the searched term
  • function getNumberResults(wikiJSON: WikiSearch_Query): number : Returns the total number of matches found for the search term. May be bigger than the results returned by wikiSearch(options)
  • function getNumberResultsListed(wikiJSON: WikiSearch_Query): number : Returns the number of results found by wikiSearch(options)
  • function getSuggestion(wikiJSON: WikiSearch_Query): string : Returns the suggested term related to the searched term
  • function hasResult(wikiJSON: WikiSearch_Query): boolean : TRUE if there are results for the searched term
  • function hasSuggestion(wikiJSON: WikiSearch_Query): boolean : TRUE if there are suggested searches related to the searched term
  • function wikiSearchQuery(options): string : Returns the url address to be used as the source to obtain the information

API: wikiParse

  • function wikiParse(options): Promise : Returns the contents of a Wikipedia page
  • function getWikiText(wikiPage: WikiParse_Query): string : Returns the original wikitext.
  • function getHTMLText(wikiPage: WikiParse_Query): string : Returns the parsed text of the wikitext.
  • function getPageTitle(wikiPage: WikiParse_Query): string : Returns the Title of Wikipedia referring to the page searched
  • function wikiParseQuery(options): string: Returns the url address to be used as the source to obtain the information

Download Details:

Author: el3um4s

Source Code: https://github.com/el3um4s/DenoWiki

deno nodejs node javascript

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

AEM Querybuilder for JavaScript (Browser, Node, Deno)

Helix Querybuilder .AEM Querybuilder for JavaScript (Browser, Node, Deno)

NKeys for JavaScript - Node.js, Browsers, and Deno

A public-key signature system based on Ed25519 for the NATS ecosystem system for JavaScript. The nkeys.js library works in Deno, Node.js, and the browser!

Javascript module for easily generating mazes,compatible with both Deno and Node

A work-in-progress Javascript maze generator module, compatible with both Deno and Node.

Deno Tutorial for Beginners: Deno vs. Node: Better Than NodeJS?

Deno is released, it’s time to find out if it can prove a worthy competition for Node.js. What is Deno? Why Deno can be considered an alternative to Node? The main differences between Deno and Node. Write a simple Deno app.

What is Deno? The Node.JS Killer? The Deno-minator to Node?

What is Deno? The Node.JS Killer? The Deno-minator to Node? Deno is the new hype and will it be better than node.js? Deno is a secure runtime for JavaScript and TypeScript that is based on the V8 JavaScript engine and the Rust programming language that addresses Node’s shortcomings