mw-category

    1.2.2 • Public • Published

    mw-category

    This library enables users to access members of a category from a mediawiki-compatible source.

    Resources

    API Reference

    Installation

    Default

    npm install mw-category
    

    Global (CLI)

    npm install -g mw-category
    

    Usage

    CLI example

    mw-category https://en.wikipedia.org/w/api.php Category:Punctuation
    

    If the --csv option is given then the resulting member strings will be quoted.

    Javascript example

    const MwCategory = require('mw-category')
     
    const CategoryLoader = MwCategory.CategoryLoader
    const MwSources = MwCategory.MwSources
     
    let loader = CategoryLoader.createFromTemplate(MwSources.Wiktionary, 'en')
    //let loader = CategoryLoader.createFromUrl('https://en.wikipedia.org/w/api.php')
     
    loader.loadMembers('Category:Spanish basic words')
      .then(
        (members) => {
          members.forEach(
            (page) => {
              console.log('page id', page.id)
              console.log('page title', page.title)
            }
          )
        }
      )
      .catch(
        (error) => console.log("error: could not load members", error)
      )

    loadMembers-Method

    Returns an Array of CategoryItem as a Promise:

    [
      {
        "id": 43130,
        "title": "vino"
      },
      {
        "id": 43709,
        "title": "tortilla"
      }
    ]

    If an error occurs then you can catch it.

    License

    MIT

    Install

    npm i mw-category

    DownloadsWeekly Downloads

    10

    Version

    1.2.2

    License

    MIT

    Unpacked Size

    1.07 MB

    Total Files

    51

    Last publish

    Collaborators

    • avatar