[SOLVED] problem in pywikibot login to third-party wiki

Jump to navigation Jump to search

When I want to login with bot to my wiki I see this error:

No handlers could be found for logger "pywiki"
Logging in to westeros:fa as SiteBot via API.
Traceback (most recent call last):
  File "C:\pywikipedia\login.py", line 436, in <module>
    main()
  File "C:\pywikipedia\login.py", line 432, in main
    loginMan.login()
  File "C:\pywikipedia\login.py", line 319, in login
    cookiedata = self.getCookie(api)
  File "C:\pywikipedia\login.py", line 181, in getCookie
    response, data = query.GetData(predata, self.site, sysop=self.sysop, back_response = True)
  File "C:\pywikipedia\pywikibot\support.py", line 121, in wrapper
    return method(*__args, **__kw)
  File "C:\pywikipedia\query.py", line 143, in GetData
    res, jsontext = site.postForm(path, params, sysop, site.cookies(sysop = sysop) )
  File "C:\pywikipedia\wikipedia.py", line 6460, in postForm
    cookies=cookies)
  File "C:\pywikipedia\wikipedia.py", line 6514, in postData
    raise PageNotFound(u'Page %s could not be retrieved. Check your family file ?' % url)
pywikibot.exceptions.PageNotFound: Page http://www.westeros.ir/w/api.php could not be retrieved. Check your family file?

My family file is this:

# -*- coding: utf-8  -*-

import family

# westeros

class Family(family.Family):
    def __init__(self):
        family.Family.__init__(self)

        self.name = 'westeros'

        self.langs = {
                'fa': 'www.westeros.ir',
        }
        
    def version(self, code):
        return "1.19.3"
	def scriptpath(self, code):
		return '/wiki'
	def apipath(self, code):
		return '/wiki'

api.php is in '/wiki' folder, why it says "Page http://www.westeros.ir/w/api.php could not be retrieved"? Where should I change "/w" to "/wiki" other than family.py file?

3dmahdi (talk)10:51, 27 June 2013

You should be using http://westeros.ir/wiki/api.php for your api.php. BTW: added to wikiapiary.

MarkAHershberger(talk)14:13, 2 July 2013

Yes, as you see I want use http://westeros.ir/wiki/api.php and defined apipath in westeros_family.py file like this:

def apipath(self, code):
               return '/wiki'

I wonder why I'm receiving this error. I never mentioned '/w' folder anywhere! Is there any way to fix this?

PS: Thanks for adding to wikiapary.

3dmahdi (talk)14:52, 3 July 2013

I'm afraid I don't know much about this. Looks like you got an answer from your post on Pywikipediabot page, though.

MarkAHershberger(talk)23:18, 4 July 2013

Yes, that was the solution. Problem was with tabs. Now my bot can login and edit pages. Thanks for your help.

3dmahdi (talk)20:12, 5 July 2013