Manual talk:Pywikibot

Jump to: navigation, search

About this board

Archives 


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
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)

Hello,

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 pwb.py listpages.py -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"
95.37.79.244 (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 page.py 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 pwb.py version

[1] https://phabricator.wikimedia.org/maniphest/task/edit/form/1/?project=pywikibot-core

Green Cardamom (talkcontribs)

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

87.100.134.231 (talkcontribs)

A Command

python2.7 pwb.py weblinkchecker.py -start:!

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

File "/chroot/python27/lib/python2.7/threading.py", 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 pwb.py version

[1] https://phabricator.wikimedia.org/maniphest/task/edit/form/1/?project=pywikibot-core

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 = 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)

The above code:

http://pastebin.com/QzSsfhRB

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"
222.167.212.50 (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 pwb.py login

May somebody help?thanks!

222.167.212.50 (talkcontribs)

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

Xqt (talkcontribs)

did you really installed python.exe?

222.167.212.50 (talkcontribs)

Yes, Python 3.5, from the official site

ԱշոտՏՆՂ (talkcontribs)

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

Xqt (talkcontribs)

Anyway python pwb.py 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"
BotAndNoob (talkcontribs)

Hello, can you help please hot to add/remove spaces in text

For exmaple "J.R.R.Tolkien" should transform to "J. R. R. Tolkien"

I tried to use replace.py and user-fixes.py

(u' \. ', u'\. '),
(u' \..?', u'\. .?'),
(u'.?\..?', u'.?\. .?'),

But that's don't work.

Hope on your help, thanks

Reply to "space adding/removing"