print('hello stroopwaffels')
hello stroopwaffels
print('hello stroopwaffels')
hello stroopwaffels
print('hello stroopwafels')
hello stroopwafels
import pywikibot #tell python that we will be using pywikibot
site=pywikibot.Site('wikidata','wikidata') #Identify the site we will use
repo=site.data_repository()                #Identify the repository
wd = pywikibot.ItemPage(repo, 'Q56095936') #Identify the wanted object in WikiData
wd.get()                                   #Get the information for the object
print('%s' % wd.labels)
print('%s' % wd.descriptions['nl'])        # Gives the description in Dutch
                                           # Raises an exception if not existing
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-4-b9de698b97aa> in <module>()
      2 site=pywikibot.Site('wikidata','wikidata') #Identify the site we will use
      3 repo=site.data_repository()                #Identify the repository
----> 4 wd = pywikibot.ItemPage(repo, 'Q56095936') #Identify the wanted object in WikiData
      5 wd.get()                                   #Get the information for the object
      6 print('%s' % wd.labels)

/srv/paws/pwb/pywikibot/page.py in __init__(self, site, title, ns)
   4313         """
   4314         if ns is None:
-> 4315             ns = site.item_namespace
   4316         # Special case for empty item.
   4317         if title is None or title == '-1':

/srv/paws/pwb/pywikibot/site.py in item_namespace(self)
   7442         """
   7443         if self._item_namespace is None:
-> 7444             self._cache_entity_namespaces()
   7445 
   7446         if isinstance(self._item_namespace, Namespace):

/srv/paws/pwb/pywikibot/site.py in _cache_entity_namespaces(self)
   7423         self._property_namespace = False
   7424 
-> 7425         for namespace in self.namespaces.values():
   7426             if not hasattr(namespace, 'defaultcontentmodel'):
   7427                 continue

/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 wikidata:wikidata: The authorization headers in your request are for a user that does not exist here
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-14-3611459da926> in <module>()
     11 tmpl_gen = list_template_usage(site, "Infobox meteorietinslag")
     12 
---> 13 for page in tmpl_gen:
     14     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
import pywikibot                            # Tell python that we will be using pywikibot
site=pywikibot.Site('nl', 'wikipedia')       # Identify the site we will use
pagename = 'User talk:%s' % site.username() # Testing, so use your bots own talk page
page = pywikibot.Page(site, pagename)       # Retrieve the current page
text = page.text                            # Retrieve the current text, which we'll change
text += '\n== Happy hacking ==\n'           # Add text. \n tells to add a newline to the text, so the content will be on different lines 
                                            # NB: in Wikicode, doesn't mean it will be so in the shown content.
text += 'Let\'s do some Python exercise. ~~~~\n'
page.text = text                            # update the text in the page object in memory
page.save ('I\'m trying to use Python and Pywikibot')  #save everything to the page
Page [[nl:Overleg gebruiker:Bakoorjakkals]] saved
import pywikibot
from pywikibot import pagegenerators as pg

for command in dir(pywikibot):
    print('pw: %s' % command)
for command in dir(pg):
    print ('pg: %s' % command)
pw: BadTitle
pw: BaseSite
pw: Bot
pw: CaptchaError
pw: CascadeLockedPage
pw: Category
pw: CircularRedirect
pw: Claim
pw: Coordinate
pw: CoordinateGlobeUnknownException
pw: CurrentPageBot
pw: Decimal
pw: EditConflict
pw: Error
pw: Family
pw: FatalServerError
pw: FilePage
pw: InterwikiRedirectPage
pw: InvalidTitle
pw: IsNotRedirectPage
pw: IsRedirectPage
pw: ItemPage
pw: Link
pw: LockedNoPage
pw: LockedPage
pw: NoCreateError
pw: NoMoveTarget
pw: NoPage
pw: NoSuchSite
pw: NoUsername
pw: OtherPageSaveError
pw: PY2
pw: Page
pw: PageCreatedConflict
pw: PageDeletedConflict
pw: PageNotSaved
pw: PageRelatedError
pw: PageSaveRelatedError
pw: PatchManager
pw: PropertyPage
pw: Queue
pw: SectionError
pw: Server504Error
pw: ServerError
pw: Site
pw: SiteDefinitionError
pw: SpamfilterError
pw: TimeStripper
pw: Timestamp
pw: TitleblacklistError
pw: UnicodeMixin
pw: UnknownExtension
pw: UnknownFamily
pw: UnknownSite
pw: UnsupportedPage
pw: User
pw: UserBlocked
pw: WbGeoShape
pw: WbMonolingualText
pw: WbQuantity
pw: WbTabularData
pw: WbTime
pw: WbUnknown
pw: WikiBaseError
pw: WikidataBot
pw: _DeprecatedPageNotFoundError
pw: _EmailUserError
pw: _MediaWikiVersion
pw: _ModuleDeprecationWrapper
pw: _QuitKeyboardInterrupt
pw: _UploadWarning
pw: _WbDataPage
pw: _WbRepresentation
pw: __all__
pw: __builtins__
pw: __cached__
pw: __deprecated
pw: __doc__
pw: __file__
pw: __loader__
pw: __name__
pw: __package__
pw: __path__
pw: __release__
pw: __spec__
pw: __url__
pw: __version__
pw: _code_fam_from_url
pw: _deprecate_arg
pw: _deprecated
pw: _flush
pw: _module
pw: _name
pw: _putthread
pw: _sites
pw: _url_cache
pw: _wbtypes
pw: absolute_import
pw: argvu
pw: async_manager
pw: async_request
pw: atexit
pw: basestring
pw: bot
pw: bot_choice
pw: calledModuleName
pw: categoryFormat
pw: classproperty
pw: color_format
pw: comms
pw: compileLinkR
pw: config
pw: config2
pw: critical
pw: daemonize
pw: data
pw: date
pw: datetime
pw: debug
pw: deprecate_arg
pw: deprecated
pw: diff
pw: division
pw: echo
pw: error
pw: exception
pw: exceptions
pw: extract_templates_and_params
pw: family
pw: getCategoryLinks
pw: getLanguageLinks
pw: getSite
pw: handleArgs
pw: handle_args
pw: html2unicode
pw: i18n
pw: input
pw: inputChoice
pw: input_choice
pw: input_yn
pw: interwikiFormat
pw: interwikiSort
pw: isDisabled
pw: link_regex
pw: log
pw: logging
pw: login
pw: long
pw: math
pw: normalize_username
pw: output
pw: page
pw: page_put_queue
pw: pagegenerators
pw: plural
pw: proofreadpage
pw: re
pw: redirect_func
pw: removeCategoryLinks
pw: removeCategoryLinksAndSeparator
pw: removeDisabledParts
pw: removeHTMLParts
pw: removeLanguageLinks
pw: removeLanguageLinksAndSeparator
pw: replaceCategoryInPlace
pw: replaceCategoryLinks
pw: replaceExcept
pw: replaceLanguageLinks
pw: setAction
pw: showDiff
pw: showHelp
pw: site
pw: sleep
pw: stdout
pw: stopme
pw: sys
pw: target
pw: textlib
pw: textlib_methods
pw: threading
pw: throttle
pw: time
pw: tools
pw: translate
pw: ui
pw: unescape
pw: unicode2html
pw: unicode_literals
pw: url2unicode
pw: userinterfaces
pw: version
pw: warn
pw: warning
pw: wrapped_func
pw: xmlreader
pg: AllpagesPageGenerator
pg: AncientPagesPageGenerator
pg: ArgumentDeprecationWarning
pg: CategorizedPageGenerator
pg: CategoryFilterPageGenerator
pg: CategoryGenerator
pg: CombinedPageGenerator
pg: DayPageGenerator
pg: DeadendPagesPageGenerator
pg: DequeGenerator
pg: DequePreloadingGenerator
pg: DuplicateFilterPageGenerator
pg: EdittimeFilterPageGenerator
pg: FileGenerator
pg: FileLinksGenerator
pg: GeneratorFactory
pg: GoogleSearchPageGenerator
pg: ImageGenerator
pg: ImagesPageGenerator
pg: InterwikiPageGenerator
pg: ItemClaimFilter
pg: ItemClaimFilterPageGenerator
pg: IteratorNextMixin
pg: LanguageLinksPageGenerator
pg: LinkedPageGenerator
pg: LinksearchPageGenerator
pg: ListOption
pg: LiveRCPageGenerator
pg: LogeventsPageGenerator
pg: LogpagesPageGenerator
pg: LonelyPagesPageGenerator
pg: LongPagesPageGenerator
pg: MySQLPageGenerator
pg: NamespaceFilterPageGenerator
pg: NewimagesPageGenerator
pg: NewpagesPageGenerator
pg: PageClassGenerator
pg: PageTitleFilterPageGenerator
pg: PageWithTalkPageGenerator
pg: PagesFromPageidGenerator
pg: PagesFromTitlesGenerator
pg: PetScanPageGenerator
pg: PrefixingPageGenerator
pg: PreloadingEntityGenerator
pg: PreloadingGenerator
pg: PreloadingItemGenerator
pg: ProofreadPage
pg: QualityFilterPageGenerator
pg: RandomPageGenerator
pg: RandomRedirectPageGenerator
pg: RecentChangesPageGenerator
pg: RecentchangesPageGenerator
pg: RedirectFilterPageGenerator
pg: ReferringPageGenerator
pg: RegexBodyFilterPageGenerator
pg: RegexFilter
pg: RegexFilterPageGenerator
pg: RepeatingGenerator
pg: SearchPageGenerator
pg: ServerError
pg: ShortPagesPageGenerator
pg: SubCategoriesPageGenerator
pg: SubpageFilterGenerator
pg: TextfilePageGenerator
pg: UnCategorizedCategoryGenerator
pg: UnCategorizedImageGenerator
pg: UnCategorizedPageGenerator
pg: UnCategorizedTemplateGenerator
pg: UnCategorizedTemplatesGenerator
pg: UnconnectedPageGenerator
pg: UnknownExtension
pg: UnusedFilesGenerator
pg: UnwatchedPagesPageGenerator
pg: UserContributionsGenerator
pg: UserEditFilterGenerator
pg: WantedPagesPageGenerator
pg: WikibaseItemFilterPageGenerator
pg: WikibaseItemGenerator
pg: WikibaseSearchItemPageGenerator
pg: WikidataItemGenerator
pg: WikidataPageFromItemGenerator
pg: WikidataSPARQLPageGenerator
pg: WithoutInterwikiPageGenerator
pg: XMLDumpOldPageGenerator
pg: XMLDumpPageGenerator
pg: YahooSearchPageGenerator
pg: YearPageGenerator
pg: __builtins__
pg: __cached__
pg: __doc__
pg: __file__
pg: __loader__
pg: __name__
pg: __package__
pg: __spec__
pg: _filter_unique_pages
pg: _int_none
pg: _logger
pg: absolute_import
pg: basestring
pg: calendar
pg: codecs
pg: config
pg: date
pg: datetime
pg: deprecated
pg: deprecated_args
pg: division
pg: docuReplacements
pg: filter_unique
pg: http
pg: i18n
pg: intersect_generators
pg: issue_deprecation_warning
pg: itergroup
pg: itertools
pg: json
pg: page_with_property_generator
pg: parameterHelp
pg: partial
pg: pywikibot
pg: re
pg: redirect_func
pg: sys
pg: timedelta
pg: unicode_literals
pg: warn
pg: xmlreader