summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlasdair <alnessy@hotmail.com>2013-08-23 19:24:35 +0200
committerAlasdair <alnessy@hotmail.com>2013-08-23 19:24:35 +0200
commitd2b13b1823fd94ff6a41fdefa11f4a6403dea779 (patch)
tree4c012fc8970c1dea653e0350d9adfcd76bf212f5
initial commit
-rwxr-xr-xwikiquery27
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()