Skip to content

Instantly share code, notes, and snippets.

@junaidpv
Created January 6, 2011 09:00
Show Gist options
  • Save junaidpv/767689 to your computer and use it in GitHub Desktop.
Save junaidpv/767689 to your computer and use it in GitHub Desktop.
Pywikipedia bot script to get list of all oneliners
"""
Bot script to get list all one liners
Author: Junaid P V (http://ml.wikipedia.org/wiki/user:Junaidpv)
"""
import wikipedia
import catlib
import codecs
NEWLINE = '\r\n'
siteFamily = 'wikipedia'
siteLangCode = 'ml'
catName = ur'ഒറ്റവരി ലേഖനങ്ങൾ'
wikiSite = wikipedia.Site(code=siteLangCode, fam=siteFamily)
#log = codecs.open('logs/pages-in-cat.log', mode='a+', encoding = 'utf-8')
listFile = codecs.open('oneliners.txt', mode = 'w+', encoding = 'utf-8')
catPage = catlib.Category(wikiSite, catName)
oneLiners = catPage.articles(recurse=True)
listString = ''
for page in oneLiners:
listString = listString + page.title()
listString = listString + NEWLINE
listFile.write(listString)
listFile.flush()
listFile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment