import pywikibot
site = pywikibot.Site('test', 'wikipedia')
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-59c357d0817c> in <module>()
----> 1 site = pywikibot.Site('test', 'wikipedia')

NameError: name 'pywikibot' is not defined
site = pywikibot.Site('test', 'wikipedia')
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-2-59c357d0817c> in <module>()
----> 1 site = pywikibot.Site('test', 'wikipedia')

NameError: name 'pywikibot' is not defined
import pywikibot
site = pywikibot.Site('test', 'wikipedia')
site
APISite("test", "wikipedia")
page = pywikibot.Page(site, 'test')
page
Page('Test')
page.exist()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-8-ffec5aa8bba5> in <module>()
----> 1 page.exist()

AttributeError: 'Page' object has no attribute 'exist'
page.exists()
True
page.text
'Hello world!!'
page.save()
Page [[Test]] saved
import pywikibot

site = pywikibot.Site('test', 'wikipedia')
page = pywikibot.Page(site, 'test')

page.text = 'Hello world!'
page.save()
Page [[Test]] saved
help(pywikibot.Site)
Help on function Site in module pywikibot:

Site(code=None, fam=None, user=None, sysop=None, interface=None, url=None)
    A factory method to obtain a Site object.
    
    Site objects are cached and reused by this method.
    
    By default rely on config settings. These defaults may all be overridden
    using the method parameters.
    
    @param code: language code (override config.mylang)
    @type code: string
    @param fam: family name or object (override config.family)
    @type fam: string or Family
    @param user: bot user name to use on this site (override config.usernames)
    @type user: unicode
    @param sysop: sysop user to use on this site (override config.sysopnames)
    @type sysop: unicode
    @param interface: site class or name of class in pywikibot.site
        (override config.site_interface)
    @type interface: subclass of L{pywikibot.site.BaseSite} or string
    @param url: Instead of code and fam, does try to get a Site based on the
        URL. Still requires that the family supporting that URL exists.
    @type url: string
    @rtype: pywikibot.site.APISite

import pywikibot

site = pywikibot.Site('test', 'wikipedia','https://www.mediawiki.org/wiki/MediaWiki')
page = pywikibot.Page(site, 'test')

#page.text = 'Hello world!'
page.save()
---------------------------------------------------------------------------
NoUsername                                Traceback (most recent call last)
/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in _save(self, summary, watch, minor, botflag, async, callback, cc, quiet, **kwargs)
   1218             done = self.site.editpage(self, summary=summary, minor=minor,
-> 1219                                       watch=watch, bot=botflag, **kwargs)
   1220             if not done:

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in callee(self, *args, **kwargs)
   1303             if grp == 'user':
-> 1304                 self.login(False)
   1305             elif grp == 'sysop':

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in login(self, sysop)
   2055                                     'wrong': self.userinfo['name'],
-> 2056                                     'right': self._username[sysop]})
   2057             else:

NoUsername: Logged in on wikipedia:test via OAuth as Sgmonusg, but expect as Https://www.mediawiki.org/wiki/MediaWiki

During handling of the above exception, another exception occurred:

OtherPageSaveError                        Traceback (most recent call last)
<ipython-input-14-a492f00d68a0> in <module>()
      5 
      6 #page.text = 'Hello world!'
----> 7 page.save()

/srv/paws/lib/python3.4/site-packages/pywikibot/tools/__init__.py in wrapper(*__args, **__kw)
   1415                              cls, depth)
   1416                     del __kw[old_arg]
-> 1417             return obj(*__args, **__kw)
   1418 
   1419         if not __debug__:

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in save(self, summary, watch, minor, botflag, force, async, callback, apply_cosmetic_changes, quiet, **kwargs)
   1206             self._save(summary=summary, watch=watch, minor=minor,
   1207                        botflag=botflag, async=async, callback=callback,
-> 1208                        cc=apply_cosmetic_changes, quiet=quiet, **kwargs)
   1209 
   1210     def _save(self, summary=None, watch=None, minor=True, botflag=None,

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in _save(self, summary, watch, minor, botflag, async, callback, cc, quiet, **kwargs)
   1232                 if isinstance(err, pywikibot.PageSaveRelatedError):
   1233                     raise err
-> 1234                 raise pywikibot.OtherPageSaveError(self, err)
   1235         if callback:
   1236             callback(self, err)

OtherPageSaveError: Edit to page [[Test]] failed:
Logged in on wikipedia:test via OAuth as Sgmonusg, but expect as Https://www.mediawiki.org/wiki/MediaWiki
import pywikibot

site = pywikibot.Site('test', 'wikipedia','sgmonusg','default','https://www.mediawiki.org/wiki/MediaWiki')
page = pywikibot.Page(site, 'test')

#page.text = 'Hello world!'
page.save()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-15-3edab8e52f7d> in <module>()
      1 import pywikibot
      2 
----> 3 site = pywikibot.Site('test', 'wikipedia','sgmonusg','default','https://www.mediawiki.org/wiki/MediaWiki')
      4 page = pywikibot.Page(site, 'test')
      5 

/srv/paws/lib/python3.4/site-packages/pywikibot/__init__.py in Site(code, fam, user, sysop, interface, url)
    804         try:
    805             tmp = __import__('pywikibot.site', fromlist=[interface])
--> 806             interface = getattr(tmp, interface)
    807         except ImportError:
    808             raise ValueError('Invalid interface name: {0}'.format(interface))

AttributeError: 'module' object has no attribute 'https://www.mediawiki.org/wiki/MediaWiki'
import pywikibot

site = pywikibot.Site('test', 'wikipedia','sgmonusg','default','default','https://www.mediawiki.org/wiki/MediaWiki')
page = pywikibot.Page(site, 'test')

#page.text = 'Hello world!'
page.save()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-16-6445126225e4> in <module>()
      1 import pywikibot
      2 
----> 3 site = pywikibot.Site('test', 'wikipedia','sgmonusg','default','default','https://www.mediawiki.org/wiki/MediaWiki')
      4 page = pywikibot.Page(site, 'test')
      5 

/srv/paws/lib/python3.4/site-packages/pywikibot/__init__.py in Site(code, fam, user, sysop, interface, url)
    750     # Either code and fam or only url
    751     if url and (code or fam):
--> 752         raise ValueError('URL to the wiki OR a pair of code and family name '
    753                          'should be provided')
    754     _logger = "wiki"

ValueError: URL to the wiki OR a pair of code and family name should be provided
import pywikibot

site = pywikibot.Site('https://www.mediawiki.org/wiki/MediaWiki')
page = pywikibot.Page(site, 'test')

#page.text = 'Hello world!'
page.save()
---------------------------------------------------------------------------
UnknownSite                               Traceback (most recent call last)
<ipython-input-17-74617ae44b94> in <module>()
      1 import pywikibot
      2 
----> 3 site = pywikibot.Site('https://www.mediawiki.org/wiki/MediaWiki')
      4 page = pywikibot.Page(site, 'test')
      5 

/srv/paws/lib/python3.4/site-packages/pywikibot/__init__.py in Site(code, fam, user, sysop, interface, url)
    814     key = '%s:%s:%s:%s' % (interface.__name__, fam, code, user)
    815     if key not in _sites or not isinstance(_sites[key], interface):
--> 816         _sites[key] = interface(code=code, fam=fam, user=user, sysop=sysop)
    817         debug(u"Instantiated %s object '%s'"
    818               % (interface.__name__, _sites[key]), _logger)

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in __init__(self, code, fam, user, sysop)
   1832     def __init__(self, code, fam=None, user=None, sysop=None):
   1833         """Constructor."""
-> 1834         BaseSite.__init__(self, code, fam, user, sysop)
   1835         self._msgcache = {}
   1836         self._loginstatus = LoginStatus.NOT_ATTEMPTED

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in __init__(self, code, fam, user, sysop)
    770             else:
    771                 raise UnknownSite(u"Language '%s' does not exist in family %s"
--> 772                                   % (self.__code, self.__family.name))
    773 
    774         self._username = [normalize_username(user), normalize_username(sysop)]

UnknownSite: Language 'https://www.mediawiki.org/wiki/mediawiki' does not exist in family wikipedia
import pywikibot

site = pywikibot.Site('test', 'wikipedia','sgmonusg','https://www.mediawiki.org/wiki/MediaWiki.')
page = pywikibot.Page(site, 'test')

#page.text = 'Hello world!'
page.save()
WARNING: API error badtoken: Invalid token
Sleeping for 9.7 seconds, 2016-09-22 21:22:05
Page [[Test]] saved