I use PywikiBot core version in linux to create a program to simply get categories of a Wikipedia page.my code is:
# -*- coding: utf-8 -*-
import pywikibot
site = pywikibot.Site("en")
page = pywikibot.Page(site, u"Wikipedia:Sandbox")
item = pywikibot.ItemPage.fromPage(page)
dictionary = item.get()
print page.categories
And i expect to get categories but i get :
<bound method Page.categories of Page(Wikipedia:Sandbox)>
I follow this tutorial but i should say documentation in pywikibot is badly written and you should open files to find out some information and i found def categories:
def categories(self, withSortKey=False, step=None, total=None,
content=False):
"""Iterate categories that the article is in.
@param withSortKey: if True, include the sort key in each Category.
@param step: limit each API call to this number of pages
@param total: iterate no more than this number of pages in total
@param content: if True, retrieve the content of the current version
of each category description page (default False)
@return: a generator that yields Category objects.
"""
return self.site.pagecategories(self, withSortKey=withSortKey,
step=step, total=total, content=content)
And i prefer no to change framework codes.