-
-
Save alphapapa/38fbaa4fed609bb0a5e0 to your computer and use it in GitHub Desktop.
w: Print summary of Wikipedia article to STDOUT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Requires wikipedia module. '$ pip install wikipedia' Put it in your | |
# path and 'chmod +x'. Then just 'w whatever' and find out what | |
# something is! :D | |
# I couldn't find a good command-line utiity to do this. | |
# wikipedia2text is okay but it does the whole page, which isn't | |
# always what I want. The old command 'dig +short txt "$1.wp.dg.cx"' | |
# doesn't work anymore. But this works well. | |
import sys | |
try: | |
import wikipedia as wp | |
except: | |
print "Requires the wikipedia module. Use 'pip install wikipedia' to install." | |
sys.exit(1) | |
s = wp.summary(str(sys.argv[1:])) | |
print s.replace('\n', '\n\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment