print('Hello stroopwafels')
Hello stroopwafels
import pywikibot
site=pywikibot.Site('wikidata','wikidata') 
repo=site.data_repository()
wd = pywikibot.ItemPage(repo, 'Q56095936')
wd.get()
print('%s' % wd.labels)
print('%s' % wd.descriptions['nl'])
{'nl': 'Wiki Techstorm', 'en': 'Wiki Techstorm', 'fr': 'Wiki Techstorm'}
Wikimedia Hackaton
print('%s' % wd.descriptions['es'])
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-3-307a342affc4> in <module>()
----> 1 print('%s' % wd.descriptions['es'])

KeyError: 'es'
import pywikibot  
site=pywikibot.Site('nl', 'wikipedia')
pagename = 'User talk:%s' % site.username()
page = pywikibot.Page(site, pagename)
text = page.text
text += '\n== Happy hacking ==\n'
text += 'Let\'s do some Python exercise. ~~~~\n'
page.text = text
page.save ('I\'m trying to use Python and Pywikibot')
Sleeping for 8.8 seconds, 2018-10-26 09:12:10
Page [[nl:Overleg gebruiker:Eamane Luinwe]] saved
print('%s' % wd.descriptions['fr'])
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-5-685b97b8732b> in <module>()
----> 1 print('%s' % wd.descriptions['fr'])

KeyError: 'fr'
print('%s' % wd.descriptions['nl'])
Wikimedia Hackaton
print('%s' % wd.descriptions['sidelinks'])
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-7-85c521b811e8> in <module>()
----> 1 print('%s' % wd.descriptions['sidelinks'])

KeyError: 'sidelinks'
print('%s' % wd.descriptions['sitelinks'])
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-8-43efa1ec7fec> in <module>()
----> 1 print('%s' % wd.descriptions['sitelinks'])

KeyError: 'sitelinks'
clear all

wd
ItemPage('Q56095936')
import pywikibot
from pywikibot import pagegenerators as pg
def list_template_usage(site_obj, tmpl_name):
    name = "{}:{}".format(site_obj.namespace(10), tmpl_name)
    tmpl_page = pywikibot.Page(site_obj, name)
    ref_gen = pg.ReferringPageGenerator(tmpl_page, onlyTemplateInclusion=True)
    filter_gen = pg.NamespaceFilterPageGenerator(ref_gen, namespaces=[0])
    generator = site_obj.preloadpages(filter_gen, pageprops=True)
    return generator
site = pywikibot.Site("nl", 'wikipedia')
tmpl_gen = list_template_usage(site, "Infobox meteorietinslag")
for page in tmpl_gen:
    print(page.title())
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-11-187deca1ef93> in <module>()
     10 site = pywikibot.Site("nl", 'wikipedia')
     11 tmpl_gen = list_template_usage(site, "Infobox meteorietinslag")
---> 12 for page in tmpl_gen:
     13     print(page.title())

/srv/paws/pwb/pywikibot/site.py in preloadpages(self, pagelist, groupsize, templates, langlinks, pageprops)
   3370         rvprop = ['ids', 'flags', 'timestamp', 'user', 'comment', 'content']
   3371 
-> 3372         for sublist in itergroup(pagelist, groupsize):
   3373             # Do not use p.pageid property as it will force page loading.
   3374             pageids = [str(p._pageid) for p in sublist

/srv/paws/pwb/pywikibot/tools/__init__.py in itergroup(iterable, size)
    918     """
    919     group = []
--> 920     for item in iterable:
    921         group.append(item)
    922         if len(group) == size:

/srv/paws/pwb/pywikibot/pagegenerators.py in NamespaceFilterPageGenerator(generator, namespaces, site)
   1697         site = pywikibot.Site()
   1698     try:
-> 1699         namespaces = site.namespaces.resolve(namespaces)
   1700     except KeyError as e:
   1701         pywikibot.log('Failed resolving namespaces:')

/srv/paws/pwb/pywikibot/site.py in namespaces(self)
   1021         """Return dict of valid namespaces on this wiki."""
   1022         if not hasattr(self, '_namespaces'):
-> 1023             self._namespaces = NamespacesDict(self._build_namespaces())
   1024         return self._namespaces
   1025 

/srv/paws/pwb/pywikibot/site.py in _build_namespaces(self)
   2643         # For versions lower than 1.14, APISite needs to override
   2644         # the defaults defined in Namespace.
-> 2645         is_mw114 = self.mw_version >= '1.14'
   2646 
   2647         for nsdata in self.siteinfo.get('namespaces', cache=False).values():

/srv/paws/pwb/pywikibot/site.py in mw_version(self)
   2777         mw_ver, cache_time = getattr(self, '_mw_version_time', (None, None))
   2778         if mw_ver is None or time.time() - cache_time > 60 * 60 * 24:
-> 2779             mw_ver = MediaWikiVersion(self.version())
   2780             setattr(self, '_mw_version_time', (mw_ver, time.time()))
   2781         return mw_ver

/srv/paws/pwb/pywikibot/site.py in version(self)
   2760             try:
   2761                 version = self.siteinfo.get('generator',
-> 2762                                             expiry=1).split(' ')[1]
   2763             except pywikibot.data.api.APIError:
   2764                 # 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)
   1670                 elif not Siteinfo._is_expired(cached[1], expiry):
   1671                     return copy.deepcopy(cached[0])
-> 1672         preloaded = self._get_general(key, expiry)
   1673         if not preloaded:
   1674             preloaded = self._get_siteinfo(key, expiry)[key]

/srv/paws/pwb/pywikibot/site.py in _get_general(self, key, expiry)
   1616                     .format("', '".join(props)), _logger)
   1617             props += ['general']
-> 1618             default_info = self._get_siteinfo(props, expiry)
   1619             for prop in props:
   1620                 self._cache[prop] = default_info[prop]

/srv/paws/pwb/pywikibot/site.py in _get_siteinfo(self, prop, expiry)
   1539         request._warning_handler = warn_handler
   1540         try:
-> 1541             data = request.submit()
   1542         except api.APIError as e:
   1543             if e.code == 'siunknown_siprop':

/srv/paws/pwb/pywikibot/data/api.py in submit(self)
   2426         cached_available = self._load_cache()
   2427         if not cached_available:
-> 2428             self._data = super(CachedRequest, self).submit()
   2429             self._write_cache(self._data)
   2430         else:

/srv/paws/pwb/pywikibot/data/api.py in submit(self)
   2253                     continue
   2254                 raise NoUsername('Failed OAuth authentication for %s: %s'
-> 2255                                  % (self.site, info))
   2256             if code == 'cirrussearch-too-busy-error':  # T170647
   2257                 self.wait()

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