import pywikibot

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

page.text = 'Hello world!'
page.save()
Sleeping for 9.5 seconds, 2016-05-13 13:10:54
Page [[Test]] saved
import pywikibot
site = pywikibot.Site("test", "wikipedia")
page = pywikibot.Page(site, u"Hillary_Clintonová")
item = pywikibot.ItemPage.fromPage(page)
dictionary = item.get()
print(dictionary)
print(dictionary.keys())
print(item)

EntityTypeUnknownExceptionTraceback (most recent call last)
<ipython-input-6-9dd96668ee53> in <module>()
      2 site = pywikibot.Site("test", "wikipedia")
      3 page = pywikibot.Page(site, u"Hillary_Clintonová")
----> 4 item = pywikibot.ItemPage.fromPage(page)
      5 dictionary = item.get()
      6 print(dictionary)

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in fromPage(cls, page, lazy_load)
   3839             # we already have the id, so use it
   3840             return cls(repo, page.properties().get('wikibase_item'))
-> 3841         i = cls(repo)
   3842         # clear id, and temporarily store data needed to lazy loading the item
   3843         del i.id

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in __init__(self, site, title, ns)
   3758         """
   3759         if ns is None:
-> 3760             ns = site.item_namespace
   3761         # Special case for empty item.
   3762         if title is None or title == '-1':

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in item_namespace(self)
   6794             raise EntityTypeUnknownException(
   6795                 '%r does not support entity type "item"'
-> 6796                 % self)
   6797 
   6798     @property

EntityTypeUnknownException: DataSite("test", "wikidata") does not support entity type "item"
import pywikibot
site = pywikibot.Site("wikidata", "wikidata")
repo = site.data_repository()
item = pywikibot.ItemPage(repo, u"Q42")
WARNING: API error mwoauth-invalid-authorization-invalid-user: The authorization headers in your request are for a user that does not exist here

NoUsernameTraceback (most recent call last)
<ipython-input-4-8f60b5c194e1> in <module>()
      1 import pywikibot
      2 site = pywikibot.Site("wikidata", "wikidata")
----> 3 repo = site.data_repository()
      4 item = pywikibot.ItemPage(repo, u"Q42")

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in data_repository(self)
   2728         req = self._simple_request(action='query', meta='wikibase')
   2729         req._warning_handler = handle_warning
-> 2730         data = req.submit()
   2731         if 'query' in data and 'wikibase' in data['query']:
   2732             data = data['query']['wikibase']['repo']['url']

/srv/paws/lib/python3.4/site-packages/pywikibot/data/api.py in submit(self)
   1893         @rtype: dict
   1894         """
-> 1895         self._add_defaults()
   1896         if (not config.enable_GET_without_SSL and
   1897                 self.site.protocol() != 'https' or

/srv/paws/lib/python3.4/site-packages/pywikibot/data/api.py in _add_defaults(self)
   1696             if ('continue' not in self._params and
   1697                     'rawcontinue' not in self._params and
-> 1698                     MediaWikiVersion(self.site.version()) >= MediaWikiVersion('1.25wmf5')):
   1699                 self._params['rawcontinue'] = ['']
   1700         if "maxlag" not in self._params and config.maxlag:

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in version(self)
   2684         if not version:
   2685             try:
-> 2686                 version = self.siteinfo.get('generator', expiry=1).split(' ')[1]
   2687             except pywikibot.data.api.APIError:
   2688                 # May occur if you are not logged in (no API read permissions).

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in get(self, key, get_default, cache, expiry)
   1649                 elif not Siteinfo._is_expired(cached[1], expiry):
   1650                     return copy.deepcopy(cached[0])
-> 1651         preloaded = self._get_general(key, expiry)
   1652         if not preloaded:
   1653             preloaded = self._get_siteinfo(key, expiry)[key]

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in _get_general(self, key, expiry)
   1595                         u"', '".join(props)), _logger)
   1596             props += ['general']
-> 1597             default_info = self._get_siteinfo(props, expiry)
   1598             for prop in props:
   1599                 self._cache[prop] = default_info[prop]

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in _get_siteinfo(self, prop, expiry)
   1521             # warnings are handled later
   1522             request._warning_handler = warn_handler
-> 1523             data = request.submit()
   1524         except api.APIError as e:
   1525             if e.code == 'siunknown_siprop':

/srv/paws/lib/python3.4/site-packages/pywikibot/data/api.py in submit(self)
   2334         cached_available = self._load_cache()
   2335         if not cached_available:
-> 2336             self._data = super(CachedRequest, self).submit()
   2337             self._write_cache(self._data)
   2338         else:

/srv/paws/lib/python3.4/site-packages/pywikibot/data/api.py in submit(self)
   2167             if 'mwoauth-invalid-authorization' in code:
   2168                 raise NoUsername('Failed OAuth authentication for %s: %s'
-> 2169                                  % (self.site, info))
   2170             # raise error
   2171             try:

NoUsername: Failed OAuth authentication for wikidata:wikidata: The authorization headers in your request are for a user that does not exist here
 
APISite("test", "wikipedia")