How to use the wtf_wikipedia.parse function in wtf_wikipedia

To help you get started, we’ve selected a few wtf_wikipedia examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github therebelrobot / countryjs / build / countryjs.build.js View on Github external
wtf_wikipedia.from_api(country.name.common, 'en', function (markup) {
      console.log(markup)
      var wiki = wtf_wikipedia.parse(markup)
      if (wiki.type === 'disambiguation') {
        console.log(country.name.common, 'disambiguation. fetching flag from +(country)')
        return wtf_wikipedia.from_api(country.name.common + ' (country)', 'en', function (markup) {
          var wiki = wtf_wikipedia.parse(markup)
          console.log(country.name.common, '(country) wiki', wiki)
          console.log(country.name.common, '(country) infobox', wiki.infobox)
          if (wiki.infobox && wiki.infobox.image_flag && wiki.infobox.image_flag.text) {
            console.log(country.name.common, '(country) flag', wiki.infobox.image_flag.text)
          }
          resolve(wiki.infobox)
        })
      }
      console.log(country.name.common, 'infobox', wiki.infobox)
      if (wiki.infobox && wiki.infobox.image_flag && wiki.infobox.image_flag.text) {
        console.log(country.name.common, 'flag', wiki.infobox.image_flag.text)
        country.flag = 'https://en.m.wikipedia.org/wiki/File:' + wiki.infobox.image_flag.text
github therebelrobot / countryjs / build / countryjs.build.js View on Github external
return wtf_wikipedia.from_api(country.name.common + ' (country)', 'en', function (markup) {
          var wiki = wtf_wikipedia.parse(markup)
          console.log(country.name.common, '(country) wiki', wiki)
          console.log(country.name.common, '(country) infobox', wiki.infobox)
          if (wiki.infobox && wiki.infobox.image_flag && wiki.infobox.image_flag.text) {
            console.log(country.name.common, '(country) flag', wiki.infobox.image_flag.text)
          }
          resolve(wiki.infobox)
        })
      }
github populr-app / populr / server / workers / wikipedia.js View on Github external
function parseExtract(markup) {
  var Intro = WikipediaApi.parse(markup).text.Intro;
  var extract = '';
  Intro.forEach(function(object) {
    extract += object.text + ' ';
  });

  return extract;
};
github ava-ia / core / src / actions / action.wikipedia.js View on Github external
wikipedia.from_api(concept, 'en', (response) => {
      const document = wikipedia.parse(response);
      if (document.type === 'page' && document.categories.length > 0) {
        const summary = document.text.Intro.map(sentence => sentence.text).join(' ');

        state.action = {
          ms: (new Date() - ms),
          engine: 'wikipedia',
          entity: entities.knowledge,
          image: `http://en.wikipedia.org/wiki/${document.images[0]}`,
          title: document.infobox.name ? document.infobox.name.text : concept,
          value: summary,
          related: extract(document.infobox),
        };

        resolve(state);
      }
    });

wtf_wikipedia

parse wikiscript into json

MIT
Latest version published 4 months ago

Package Health Score

70 / 100
Full package analysis