2005/10/6, Jason Y. Lee <jylee(a)cs.ucr.edu>du>:
I don't know how to configure your bot to post to
Wikisource, nor do I know
how you can post to the Wikisource using the pywikipedia (it's been mentioned
before, but I haven't really paid any attention to it) but here is a code
sample that you can use to rely on:
f = file('1.txt')
text = f.read()
f.close()
comment = 'My book'
# Take the text and use it to post a page.
# Example with Wikipedia:
page = wikipedia.Page(wikipedia.getSite(), 'mybook/1').put(text, comment)
You might want to check the python documentation on reading directories, then
you can loop on files within that directory.
It should work with wikisource just as well as with Wikipedia, just put
family = 'wikisource'
in your user_config.py should do the trick.
To make code like the above work correctly, there's a little bit more
work to do:
import wikipedia
try:
<insert your code here>
finally:
wikipedia.stopme()
The "import wikipedia" is necessary to be able to use the wikipediabot
framework. The "stopme()" is necessary to avoid slowing down when
running the bot several times consecutively.
--
Andre Engels, andreengels(a)gmail.com
ICQ: 6260644 -- Skype: a_engels