Hi friends, I'm new to bots and have tried to read up on this list's archives, pages on meta, and the pywikipedia bot's source code. (I'm new to python too, but that's a smaller problem.)
What I want is to upload a book to Wikisource. It comes in several parts, which should be subpages to the book's main page, e.g. my_book/1, my_book/2, etc. I have 1.txt, 2.txt etc. as plain (wiki)text files in a directory on my disk.
Is pywikipedia the right tool for this task? Should I use replace.py? Do I need to modify the source?
-- Lars Aronsson (lars@aronsson.se) Aronsson Datateknik - http://aronsson.se
On Wed, Oct 05, 2005 at 11:18:11PM +0200, Lars Aronsson wrote:
Hi friends, I'm new to bots and have tried to read up on this list's archives, pages on meta, and the pywikipedia bot's source code. (I'm new to python too, but that's a smaller problem.)
What I want is to upload a book to Wikisource. It comes in several parts, which should be subpages to the book's main page, e.g. my_book/1, my_book/2, etc. I have 1.txt, 2.txt etc. as plain (wiki)text files in a directory on my disk.
Is pywikipedia the right tool for this task? Should I use replace.py? Do I need to modify the source?
-- Lars Aronsson (lars@aronsson.se) Aronsson Datateknik - http://aronsson.se _______________________________________________ Wikibots-l mailing list Wikibots-l@wikimedia.org http://mail.wikipedia.org/mailman/listinfo/wikibots-l
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.
2005/10/6, Jason Y. Lee jylee@cs.ucr.edu:
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@gmail.com ICQ: 6260644 -- Skype: a_engels
wikibots-l@lists.wikimedia.org