import pywikibot
site = pywikibot.Site('test', 'wikipedia')
site
APISite("test", "wikipedia")
page = pywikibot.Page(site, 'test')
page.exists()
True
page.text
'Hello World'
page.text = 'Hello world!'
page.save
<bound method Page.save of Page('Test')>
page.save()
Page [[Test]] saved
page.text
'Hello world!'
help(page.save)
Help on method save in module pywikibot.page:

save(...) method of pywikibot.page.Page instance
    Save the current contents of page's text to the wiki.
    
    @param summary: The edit summary for the modification (optional, but
        most wikis strongly encourage its use)
    @type summary: unicode
    @param watch: Specify how the watchlist is affected by this edit, set
        to one of "watch", "unwatch", "preferences", "nochange":
        * watch: add the page to the watchlist
        * unwatch: remove the page from the watchlist
        * preferences: use the preference settings (Default)
        * nochange: don't change the watchlist
        If None (default), follow bot account's default settings
    
        For backward compatibility watch parameter may also be boolean:
        if True, add or if False, remove this Page to/from bot
        user's watchlist.
    @type watch: string, bool (deprecated) or None
    @param minor: if True, mark this edit as minor
    @type minor: bool
    @param botflag: if True, mark this edit as made by a bot (default:
        True if user has bot status, False if not)
    @param force: if True, ignore botMayEdit() setting
    @type force: bool
    @param async: if True, launch a separate thread to save
        asynchronously
    @param callback: a callable object that will be called after the
        page put operation. This object must take two arguments: (1) a
        Page object, and (2) an exception instance, which will be None
        if the page was saved successfully. The callback is intended for
        use by bots that need to keep track of which saves were
        successful.
    @param apply_cosmetic_changes: Overwrites the cosmetic_changes
        configuration value to this value unless it's None.
    @type apply_cosmetic_changes: bool or None
    @param quiet: enable/disable successful save operation message;
        defaults to False.
        In async mode, if True, it is up to the calling bot to manage the
        ouput e.g. via callback.
    @type quiet: bool

site = pywikibot.Site("en", "wikipedia")
page = pywikibot.Page(site, "Douglas Adams")
item = pywikibot.ItemPage.fromPage(page)

print(item)
WARNING: API error mwoauth-invalid-authorization-invalid-user: The authorization headers in your request are for a user that does not exist here
---------------------------------------------------------------------------
NoUsername                                Traceback (most recent call last)
<ipython-input-9-de654eb1f32f> in <module>()
      3 site = pywikibot.Site("en", "wikipedia")
      4 page = pywikibot.Page(site, "Douglas Adams")
----> 5 item = pywikibot.ItemPage.fromPage(page)
      6 
      7 print(item)

/srv/paws/pwb/pywikibot/page.py in fromPage(cls, page, lazy_load)
   4028         i._site = page.site
   4029         i._title = page.title(withSection=False)
-> 4030         if not lazy_load and not i.exists():
   4031             raise pywikibot.NoPage(i)
   4032         return i

/srv/paws/pwb/pywikibot/page.py in exists(self)
   3557         if not hasattr(self, '_content'):
   3558             try:
-> 3559                 self.get(get_redirect=True)
   3560                 return True
   3561             except pywikibot.NoPage:

/srv/paws/pwb/pywikibot/page.py in get(self, force, get_redirect, *args, **kwargs)
   4043         @raise NotImplementedError: a value in args or kwargs
   4044         """
-> 4045         data = super(ItemPage, self).get(force, *args, **kwargs)
   4046 
   4047         if self.isRedirectPage() and not get_redirect:

/srv/paws/pwb/pywikibot/page.py in get(self, force, *args, **kwargs)
   3646                 self.claims[pid] = []
   3647                 for claim in self._content['claims'][pid]:
-> 3648                     c = Claim.fromJSON(self.repo, claim)
   3649                     c.on_item = self
   3650                     self.claims[pid].append(c)

/srv/paws/pwb/pywikibot/page.py in fromJSON(cls, site, data)
   4477             # The default covers string, url types
   4478             claim.target = Claim.TARGET_CONVERTER.get(
-> 4479                 claim.type, lambda value, site: value)(value, site)
   4480         if 'rank' in data:  # References/Qualifiers don't have ranks
   4481             claim.rank = data['rank']

/srv/paws/pwb/pywikibot/page.py in <lambda>(value, site)
   4417             PropertyPage(site, 'P' + str(value['numeric-id'])),
   4418         'commonsMedia': lambda value, site:
-> 4419             FilePage(pywikibot.Site('commons', 'commons'), value),
   4420         'globe-coordinate': pywikibot.Coordinate.fromWikibase,
   4421         'time': lambda value, site: pywikibot.WbTime.fromWikibase(value),

/srv/paws/pwb/pywikibot/tools/__init__.py in wrapper(*__args, **__kw)
   1446                              cls, depth)
   1447                     del __kw[old_arg]
-> 1448             return obj(*__args, **__kw)
   1449 
   1450         if not __debug__:

/srv/paws/pwb/pywikibot/page.py in __init__(self, source, title)
   2301         """Constructor."""
   2302         self._file_revisions = {}  # dictionary to cache File history.
-> 2303         super(FilePage, self).__init__(source, title, 6)
   2304         if self.namespace() != 6:
   2305             raise ValueError(u"'%s' is not in the file namespace!" % title)

/srv/paws/pwb/pywikibot/tools/__init__.py in wrapper(*__args, **__kw)
   1446                              cls, depth)
   1447                     del __kw[old_arg]
-> 1448             return obj(*__args, **__kw)
   1449 
   1450         if not __debug__:

/srv/paws/pwb/pywikibot/page.py in __init__(self, source, title, ns)
   2177                 raise ValueError(u'Title must be specified and not empty '
   2178                                  'if source is a Site.')
-> 2179         super(Page, self).__init__(source, title, ns)
   2180 
   2181     @deprecate_arg("get_redirect", None)

/srv/paws/pwb/pywikibot/page.py in __init__(self, source, title, ns)
    161 
    162         if isinstance(source, pywikibot.site.BaseSite):
--> 163             self._link = Link(title, source=source, defaultNamespace=ns)
    164             self._revisions = {}
    165         elif isinstance(source, Page):

/srv/paws/pwb/pywikibot/page.py in __init__(self, text, source, defaultNamespace)
   5084         # See bug T104864, defaultNamespace might have been deleted.
   5085         try:
-> 5086             self._defaultns = self._source.namespaces[defaultNamespace]
   5087         except KeyError:
   5088             self._defaultns = defaultNamespace

/srv/paws/pwb/pywikibot/site.py in namespaces(self)
   1012         """Return dict of valid namespaces on this wiki."""
   1013         if not hasattr(self, '_namespaces'):
-> 1014             self._namespaces = NamespacesDict(self._build_namespaces())
   1015         return self._namespaces
   1016 

/srv/paws/pwb/pywikibot/site.py in _build_namespaces(self)
   2610         # For versions lower than 1.14, APISite needs to override
   2611         # the defaults defined in Namespace.
-> 2612         is_mw114 = MediaWikiVersion(self.version()) >= MediaWikiVersion('1.14')
   2613 
   2614         for nsdata in self.siteinfo.get('namespaces', cache=False).values():

/srv/paws/pwb/pywikibot/site.py in version(self)
   2723         if not version:
   2724             try:
-> 2725                 version = self.siteinfo.get('generator', expiry=1).split(' ')[1]
   2726             except pywikibot.data.api.APIError:
   2727                 # May occur if you are not logged in (no API read permissions).

/srv/paws/pwb/pywikibot/site.py in get(self, key, get_default, cache, expiry)
   1674                 elif not Siteinfo._is_expired(cached[1], expiry):
   1675                     return copy.deepcopy(cached[0])
-> 1676         preloaded = self._get_general(key, expiry)
   1677         if not preloaded:
   1678             preloaded = self._get_siteinfo(key, expiry)[key]

/srv/paws/pwb/pywikibot/site.py in _get_general(self, key, expiry)
   1620                         u"', '".join(props)), _logger)
   1621             props += ['general']
-> 1622             default_info = self._get_siteinfo(props, expiry)
   1623             for prop in props:
   1624                 self._cache[prop] = default_info[prop]

/srv/paws/pwb/pywikibot/site.py in _get_siteinfo(self, prop, expiry)
   1546             # warnings are handled later
   1547             request._warning_handler = warn_handler
-> 1548             data = request.submit()
   1549         except api.APIError as e:
   1550             if e.code == 'siunknown_siprop':

/srv/paws/pwb/pywikibot/data/api.py in submit(self)
   2340         cached_available = self._load_cache()
   2341         if not cached_available:
-> 2342             self._data = super(CachedRequest, self).submit()
   2343             self._write_cache(self._data)
   2344         else:

/srv/paws/pwb/pywikibot/data/api.py in submit(self)
   2173                     continue
   2174                 raise NoUsername('Failed OAuth authentication for %s: %s'
-> 2175                                  % (self.site, info))
   2176             # raise error
   2177             try:

NoUsername: Failed OAuth authentication for commons:commons: The authorization headers in your request are for a user that does not exist here