dartpedia 1.6.6 copy "dartpedia: ^1.6.6" to clipboard
dartpedia: ^1.6.6 copied to clipboard

discontinued

API Wrapper for the MediaWiki API. Used to gather information from any Wikipedia Page.

example/README.md

Examples: #

The following are example programs using the dartpedia package:

  • Getting all unique words in a given Wikipedia Page
  • Getting the sum of all lengths of words in a given Wikipedia's Sub Pages
  • Getting all related topics to a given topic

Examples #

Getting all unique words in a given Wikipedia Page: #

import 'package:dartpedia/dartpedia.dart' as wiki;
main() async {
  var words = [];
  try {
    var page = await wiki.page('New York City');
    var pageContents = ((page.content).split(' '));
    pageContents.forEach((e) {
      if (!words.contains(e)) {
        words.add(e);
      }
    });
  } catch (exception) {
    print(exception);
  }
  print(words);
}

Summing up the lengths of all the words in each sub page of a given topic: #

import 'package:dartpedia/dartpedia.dart' as wiki;
int addWordsInPage(wiki.WikipediaPage page) {
  print('Summing Words in: ${page.title}');
  int subSum = 0;
  ((page.content).split(' ')).forEach((e) => {subSum += e.length});
  return subSum;
}
main() async {
  int sum = 0;
  try {
    var page = await wiki.page('\"Hello, World!\" program');
    for (var x in page.links) {
      var subPage = await wiki.page(x);
      sum += addWordsInPage(subPage);
    }
  } catch (ex) {
    print(ex);
  }
  print('Total $sum');
}
import 'package:dartpedia/dartpedia.dart' as wiki;

main() async {
  var relatedTopics = await wiki.search('California');
  print(relatedTopics);
}
7
likes
40
pub points
19%
popularity

Publisher

unverified uploader

API Wrapper for the MediaWiki API. Used to gather information from any Wikipedia Page.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

dio, test

More

Packages that depend on dartpedia