Manual talk:Pywikipediabot

From MediaWiki.org
Jump to: navigation, search

Contents

Thread titleRepliesLast modified
NameError: global name 'appendtops' is not defined209:02, 22 May 2013
Bot not work on min Wikipedia119:32, 2 May 2013
createitem in rewrite branch120:44, 30 April 2013
Some bugs422:01, 25 March 2013
Versions on other wikis?004:47, 9 March 2013
Text after reflinks215:07, 20 January 2013
Must use Monobook to run Pywikipediabot?111:58, 19 January 2013
API Issues...008:16, 27 June 2012

NameError: global name 'appendtops' is not defined

Hi,

I got an issue on pywikipediabot today when I was using pagefromfile.py script to generate pages to my SMW box from template files. Please see below:

mediawiki@ontodiaAZ:~/core/pywikipedia$ python pagefromfile.py -appendtop

No handlers could be found for logger "pywiki" Reading 'dict.txt'...

>>> Resource/postalCode/12698 <<<

Traceback (most recent call last):

 File "pagefromfile.py", line 365, in <module>
   main()
 File "pagefromfile.py", line 361, in main
   bot.run()
 File "pagefromfile.py", line 159, in run
   self.put(title, contents)
 File "pagefromfile.py", line 188, in put
   if appendtops.find(self.nocontents)==-1 and appendtops.find(self.nocontents.lower())==-1:

NameError: global name 'appendtops' is not defined

I have checked the script itself but cannot see the declaration of variable 'appendtops', can anybody help? Much thanks ahead!

Akkking (talk)22:12, 7 May 2013

The issue has been resolved. If anyone has the similar issue and cannot resolve it please kindly let me know.

Akkking (talk)21:03, 20 May 2013
 

aji.mariyil@gmail.com / AjikkuttanMariyil

106.76.110.1409:02, 22 May 2013
 

Bot not work on min Wikipedia

What needs to be bot to work on Min Wikipedia?

Kolega2357 (talk)15:40, 1 May 2013

What error are you having?

Legoktm (talk)19:32, 2 May 2013
 

createitem in rewrite branch

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

ChongDae (talk)05:39, 30 April 2013
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.

Legoktm (talk)20:44, 30 April 2013
 
Edited by author.
Last edit: 14:19, 20 January 2013

I use this software on this site as Abcbot.

I input the text below in the cmd:

replace.py -ns:0 樹 树 -search:樹

and find this page. I pressed "y". Then it returned:

HTTPError: 500 Internal Server Error
WARNING: Could not open 'http://zh.minecraftwiki.net/api.php'.
Maybe the server is down. Retrying in 1 minutes...
HTTPError: 500 Internal Server Error
WARNING: Could not open 'http://zh.minecraftwiki.net/api.php'.
Maybe the server is down. Retrying in 2 minutes...
HTTPError: 500 Internal Server Error
WARNING: Could not open 'http://zh.minecraftwiki.net/api.php'.
Maybe the server is down. Retrying in 4 minutes...
HTTPError: 500 Internal Server Error
WARNING: Could not open 'http://zh.minecraftwiki.net/api.php'.
Maybe the server is down. Retrying in 8 minutes...
HTTPError: 500 Internal Server Error
WARNING: Could not open 'http://zh.minecraftwiki.net/api.php'.
Maybe the server is down. Retrying in 16 minutes...

After a while, it returned:

Traceback (most recent call last):
  File "C:\Documents and Settings\user\My Documents\pywikipedia\wikipedia.py", l
ine 8902, in async_put
    page.put(newtext, comment, watchArticle, minorEdit, force)
  File "C:\Documents and Settings\user\My Documents\pywikipedia\wikipedia.py", l
ine 2056, in put
    sysop = sysop, botflag=botflag, maxTries=maxTries)
  File "C:\Documents and Settings\user\My Documents\pywikipedia\wikipedia.py", l
ine 2147, in _putPage
    response, data = query.GetData(params, self.site(), sysop=sysop, back_respon
se = True)
  File "C:\Documents and Settings\user\My Documents\pywikipedia\pywikibot\suppor
t.py", line 115, in wrapper
    return method(*__args, **__kw)
  File "C:\Documents and Settings\user\My Documents\pywikipedia\query.py", line
143, in GetData
    res, jsontext = site.postForm(path, params, sysop, site.cookies(sysop = syso
p) )
  File "C:\Documents and Settings\user\My Documents\pywikipedia\wikipedia.py", l
ine 6107, in postForm
    cookies=cookies)
  File "C:\Documents and Settings\user\My Documents\pywikipedia\wikipedia.py", l
ine 6151, in postData
    f = MyURLopener.open(request)
  File "C:\Python27\lib\urllib2.py", line 406, in open
    response = meth(req, response)
  File "C:\Python27\lib\urllib2.py", line 519, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Python27\lib\urllib2.py", line 444, in error
    return self._call_chain(*args)
  File "C:\Python27\lib\urllib2.py", line 378, in _call_chain
    result = func(*args)
  File "C:\Python27\lib\urllib2.py", line 527, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 503: Service Unavailable

What should I do?

一個正常人 (talk)12:53, 20 January 2013

Then I use other word to replace. It sucessed. So strange!

一個正常人 (talk)12:55, 20 January 2013

The second bug is the bot change my words into question mark. See the contribution of my bot.

一個正常人 (talk)08:58, 21 January 2013

I don't see any question marks at the given link or the difflinks. Please give a difflink where you see them. This must be a character encoding problem in your browser (or in your command line).

Bináristalk22:01, 25 March 2013
 
 

These are clearly HTTP errors as stated. The problem is with the server, not the bot. Try again later or contact the maintainer of the wiki.

Bináristalk21:59, 25 March 2013
 

Versions on other wikis?

I'm not sure how useful these links are, or if they should be included as translations somehow, but I am just copying the template m:Template:Pywiki-lang's content:

es - fa - fr - hu - ja - nl - pt -

Since the template will be deleted on Meta-Wiki, I figured I should at least archive the translations somewhere more relevant, maybe here.

πr2 (tc)04:47, 9 March 2013

Text after reflinks

Sorry, can pywikipediabot automatically add templates or other text after reflinks on certain sites? For example: [1], [2]. Thanks.

Your example is just your user page.

一個正常人 (talk)12:42, 20 January 2013

Yes, I know. This is just an example. But is it possible in principle to search through the links on a web site and add text after each link? In Russian Wikipedia rules have changed, and now it is impossible without the consent of the administrator use spamremove.py . After linking to sites that may spread Malicious Software, it is necessary to put the template. Thank you.

 
 

Must use Monobook to run Pywikipediabot?

I read the Traditional Chinese Version, it says you must use Monobook skin to run Pywikipediabot, is it real at present?

一個正常人 (talk)13:43, 18 January 2013

It seems it can use in Vector skin.

一個正常人 (talk)11:58, 19 January 2013
 

API Issues...

I am trying to setup pywikipedia on my wiki (www.imfdb.org). I cannot get it work though. I either get a "No JSON object could be decoded" error or the connection just times out. Anyone with experience using pywikipedia willing to help me out? I would be eternally grateful! Below is some of the necessary code:

imfdb_family.py

# -*- coding: utf-8 -*-
"""
This family file was auto-generated by $Id: generate_family_file.py 9734 2011-11-09 22:17:11Z valhallasw $
Configuration parameters:
  url = http://www.imfdb.org/w/index.php
  name = imfdb

Please do not commit this to the SVN repository!
"""

import family

class Family(family.Family):
    def __init__(self):
        family.Family.__init__(self)
        self.name = 'imfdb'
        self.langs = {
            'en': u'www.imfdb.org',
        }

        self.namespaces[4] = self.namespaces.get(4, {})
        self.namespaces[4]['en'] = [u'imfdb :. guns in movies :. movie guns :. the internet movie firearms database']
        self.namespaces[5] = self.namespaces.get(5, {})
        self.namespaces[5]['en'] = [u'imfdb :. guns in movies :. movie guns :. the internet movie firearms database talk']
        self.namespaces[6] = self.namespaces.get(6, {})
        self.namespaces[6]['en'] = [u'Image']
        self.namespaces[7] = self.namespaces.get(7, {})
        self.namespaces[7]['en'] = [u'Image talk']


    def scriptpath(self, code):
        return {
            'en': u'/w',
        }[code]

    def version(self, code):
        return {
            'en': u'1.16.2',
        }[code]

user-config.py

mylang = 'en'
usernames['imfdb']['en']=u'CleanupBot'
family = 'imfdb'

THANKS!

Zackmann08 (talk)19:04, 26 June 2012