Topic on Manual talk:Pywikibot

GreenC bot (talkcontribs)

I'm not familiar with Python or Pywikibot but believe it could do this easily. A script passed three command-line arguments (article name, edit summary, local filename) replaces the article with the contents of local filename. Just uploads new wiki-source overwriting the existing article.

I tried something like this but it didn't work

import pywikibot, sys

  1. Usage: savepage [article name] [edit comment] [local file]

f = open(sys.argv[3], 'r') newtext = f.read()

site = pywikibot.Site('en', 'wikipedia') page = pywikibot.Page(site, sys.argv[1]) page.text = newtext page.save(sys.argv[2])

GreenC bot (talkcontribs)
Xqt (talkcontribs)

use basic.py as a very basic script and use it in that way you need.

GreenC bot (talkcontribs)

Actually it seems to work now by changing

page.text = newtext.decode('utf-8')

Xqt (talkcontribs)

You may try pagefromfile.py which is a ready-to-use script uploading pages given by file.

Reply to "Script request/help"