-
Notifications
You must be signed in to change notification settings - Fork 0
/
get.py
36 lines (26 loc) · 812 Bytes
/
get.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- coding: utf-8 -*-
"""
Very simple script which gets a page and writes its contents to
standard output. This makes it possible to pipe the text to another
process.
Syntax: python get.py Title of the page
Example: python get.py Wikipedia | grep MediaWiki > results.txt
"""
# (C) Daniel Herding, 2005
#
# Distributed under the terms of the MIT license.
__version__='$Id$'
import wikipedia as pywikibot
def main():
singlePageTitleParts = []
for arg in pywikibot.handleArgs():
singlePageTitleParts.append(arg)
pageTitle = " ".join(singlePageTitleParts)
page = pywikibot.Page(pywikibot.getSite(), pageTitle)
# TODO: catch exceptions
pywikibot.output(page.get(), toStdout = True)
if __name__ == "__main__":
try:
main()
finally:
pywikibot.stopme()