In [1]:
import pywikibot
In [2]:
site = pywikibot.Site('test', 'wikipedia')
In [3]:
site
Out[3]:
APISite("test", "wikipedia")
In [4]:
page = pywikibot.Page(site, 'test')
In [5]:
page.exists()
Out[5]:
True
In [6]:
page.text
Out[6]:
'#REDIRECT [[Mnau]]'
In [7]:
page.text
Out[7]:
'#REDIRECT [[Mnau]]'
In [8]:
page.text = 'Hello world'
In [9]:
page.save()
Page [[Test]] saved
In [10]:
page.text
Out[10]:
'Hello world'
In [11]:
page.save()
Page [[Test]] saved
In [12]:
page.text
Out[12]:
'Hello world'
In [13]:
site = pywikibot.Site('www', 'wikipedia')
---------------------------------------------------------------------------
UnknownSite                               Traceback (most recent call last)
<ipython-input-13-8eca61cd560f> in <module>()
----> 1 site = pywikibot.Site('www', 'wikipedia')

/srv/paws/pwb/pywikibot/__init__.py in Site(code, fam, user, sysop, interface, url)
    883     key = '%s:%s:%s:%s' % (interface.__name__, fam, code, user)
    884     if key not in _sites or not isinstance(_sites[key], interface):
--> 885         _sites[key] = interface(code=code, fam=fam, user=user, sysop=sysop)
    886         debug(u"Instantiated %s object '%s'"
    887               % (interface.__name__, _sites[key]), _logger)

/srv/paws/pwb/pywikibot/site.py in __init__(self, code, fam, user, sysop)
   1855     def __init__(self, code, fam=None, user=None, sysop=None):
   1856         """Constructor."""
-> 1857         BaseSite.__init__(self, code, fam, user, sysop)
   1858         self._msgcache = {}
   1859         self._loginstatus = LoginStatus.NOT_ATTEMPTED

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

UnknownSite: Language 'www' does not exist in family wikipedia
In [15]:
site = pywikibot.Site('wikipedia')
---------------------------------------------------------------------------
UnknownSite                               Traceback (most recent call last)
<ipython-input-15-99ddaa36fc25> in <module>()
----> 1 site = pywikibot.Site('wikipedia')

/srv/paws/pwb/pywikibot/__init__.py in Site(code, fam, user, sysop, interface, url)
    883     key = '%s:%s:%s:%s' % (interface.__name__, fam, code, user)
    884     if key not in _sites or not isinstance(_sites[key], interface):
--> 885         _sites[key] = interface(code=code, fam=fam, user=user, sysop=sysop)
    886         debug(u"Instantiated %s object '%s'"
    887               % (interface.__name__, _sites[key]), _logger)

/srv/paws/pwb/pywikibot/site.py in __init__(self, code, fam, user, sysop)
   1855     def __init__(self, code, fam=None, user=None, sysop=None):
   1856         """Constructor."""
-> 1857         BaseSite.__init__(self, code, fam, user, sysop)
   1858         self._msgcache = {}
   1859         self._loginstatus = LoginStatus.NOT_ATTEMPTED

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

UnknownSite: Language 'wikipedia' does not exist in family wikipedia
In [16]:
site = pywikibot.Site('en', 'wikipedia')
In [ ]: