From d2b13b1823fd94ff6a41fdefa11f4a6403dea779 Mon Sep 17 00:00:00 2001 From: Alasdair Date: Fri, 23 Aug 2013 19:24:35 +0200 Subject: initial commit --- wikiquery | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 wikiquery 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() -- cgit v1.2.3