diff options
Diffstat (limited to 'wikiquery')
-rwxr-xr-x | wikiquery | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/wikiquery b/wikiquery new file mode 100755 index 0000000..1d7b129 --- /dev/null +++ b/wikiquery @@ -0,0 +1,27 @@ +#! /usr/bin/env python + +import argparse +import wikipedia + +def parse_args(): + parser = argparse.ArgumentParser() + + parser.add_argument("topic", nargs=1) + parser.add_argument("--search", action="store_true") + parser.add_argument("--url", action="store_true") + + return parser.parse_args() + +def main(): + args = parse_args() + + if args.search: + print wikipedia.search(args.topic) + elif args.url: + page = wikipedia.page(args.topic) + print page.url + else: + print wikipedia.summary(args.topic) + +if __name__ == "__main__": + main() |