Manual talk:Pywikibot

Jump to: navigation, search

About this board

Edit description

Please use one of the communication channels listed on Manual:Pywikibot/Communication rather than using this discussion board. There is very little traffic here, so it may take a while before you get a response.

By clicking "Add topic", you agree to our Terms of Use and agree to irrevocably release your text under the CC BY-SA 3.0 License and GFDL
Aschroet (talkcontribs)

Is there any script i can use to replace the whole wiki text of a page? I only found which replaces a list of words or which can add texts to the existing one. Has somebody a hint for me?

Xqt (talkcontribs) could do it: replace -regex ".*" "Any text you want to have on this page" -page:user:Aschroet/sandbox

Xqt (talkcontribs)

Better use: replace -regex "(?s).+" "Any text you want to have on this page" -page:user:Aschroet/sandbox

Aschroet (talkcontribs)

Thank you. A batch replacement is not possible, or?

Xqt (talkcontribs)

For small text you may use -pairsfile. Another ideas is using fixes. You have to modify your for replacement.

I think the best script would be using; refer -help for mor Information about that.

Reply to "Replace the whole text"
ChongDae (talkcontribs)

I'm porting my script from trunk to rewrite branch. How can I create item in wikidata?

Legoktm (talkcontribs)
import pywikibot
site = pywikibot.Site('en', 'wikipedia')
repo = site.data_repository()

data = {'sitelinks': {'site':'enwiki', 'title':'Main Page'}}
something = repo.editEntity({}, data, bot=True)
print something

It is in the roadmap to make this an ItemPage constructor in the future.

Edoderoo (talkcontribs)

thanks... been looking a while for this!

Reply to "createitem in rewrite branch"
Framawiki (talkcontribs)


I've this error when I try to save a page with OAuth. It works with password login.

pywikibot.exceptions.OtherPageSaveError: Edit to page wiktionary:fr:Discussion utilisateur:Benoît Prieur failed:
Logged in on wiktionary:fr via OAuth as Framabot, but expect as None
CRITICAL: Closing network session.

Any idea ? Thank you.

Framawiki (talkcontribs)

Just add username in user-config :)

Framawiki (talkcontribs)

Hi, I post this strange comportment here.

python -transcludes:Utilisateur:Épiméthée/Vauban-Intelligence -lang:fr

print nothing, but Special:Linked pages list a few articles (replaced after, empty now).

When I delete the redirect, pywikibot find pages.

Thank you

Xqt (talkcontribs)

Please use Phabricator to file a bug. Anyway there are not transclusions for that page. use -ref Option instead of -transcludes to find links pointed to this site. Refer listpages -help.

Framawiki (talkcontribs)

Thanks, I will try next time this command.

XXN (talkcontribs)

IMO, old version of the PWB Manual main page was better :) Everythink is needed was easily visible and easily accesible.

Reply to "About Manual:Pywikibot" (talkcontribs)

After I'm run Pywikibot based script via cron, I'm get system mail with all pywikibot.output text. Single problem - all Russian symbols have been replaced to English via some sort of translit. How can I'm change this behavior? I'm need utf-8 log of script output, not ASCII-only.

Reply to "Pywikibot and cron"
Summary by Green Cardamom

Actually correctly flagging as a bot edit.

Green Cardamom (talkcontribs)

For some reason my Pywikibot edits are not marked as bot edits. I've tried hard-coding in so the botedit variable is True throughout. My login ID is a registered bot and should default as a bot edit. Is there something else I should do?

Xqt (talkcontribs)

Please file this at phabricator [1] and add the result of version


Green Cardamom (talkcontribs)

Yeah as noted there is actually no problem with pwb the problem doesn't exist.. this entire thread could be deleted (talkcontribs)

A Command

python2.7 -start:!

works fine few seconds (retrieves 240 pages, finds a broken link) but then:

File "/chroot/python27/lib/python2.7/", line 743, in start

_start_new_thread(self.__bootstrap, ())

thread.error: can't start new thread

<class 'thread.error'>

Any idea what to do to fix this? Thank you.

Xqt (talkcontribs)

Please file this bug at phabricator [1] and add the full traceback and the result of version


Reply to "Can't start new thread -error"
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 =

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

GreenC bot (talkcontribs)

The above code:

Xqt (talkcontribs)

use 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 which is a ready-to-use script uploading pages given by file.

Reply to "Script request/help" (talkcontribs)

When I run the following lines into the command prompt, it tells me an error that there is no such a command, files, etc. of the name python

 cd "d:\pywikibot"
 python login

May somebody help?thanks! (talkcontribs)

And it also did say is not a command or file too

Xqt (talkcontribs)

did you really installed python.exe? (talkcontribs)

Yes, Python 3.5, from the official site

ԱշոտՏՆՂ (talkcontribs)

Are you Windows user? In that case you do not need to write "python login", just " login"

Xqt (talkcontribs)

Anyway python login should work too. Seems the python installation wasn't correct because neither the python.exe nor the .py file is registered in a right way.

ԱշոտՏՆՂ (talkcontribs)

Screenshot on Windows 8.1

Reply to "Can't config pywikibot"