Hi Chris,

On 21 February 2012 02:00, Chris Watkins <chriswaterguy@appropedia.org> wrote:
Is there a way to get a bot to list pageviews for all pages in a category? I found mentions of self.counter has to do with pageviews, but I can't find a script that uses it.

I cannot find any reference to a counter that has to do with pageviews in the framework; they seem all related to counting something else (e.g. the number of categories, or the number of edits).

The API does expose a 'counter' item, however: http://www.mediawiki.org/wiki/API:Properties

I was asked: "Do you have a bot that can report the page view counts for the pages in the http://www.appropedia.org/Category:JMC330_International_Mass_Communication category?"


You can call the API directly from the framework, for example:
 >>> import wikipedia
>>> site = wikipedia.getSite('en', 'appropedia')
>>> p = wikipedia.Page(site, 'Category:JMC330_International_Mass_Communication')
>>> import query
>>> query.GetData({'action': 'query', 'prop': 'info', 'titles': p.title()}, site)['query']['pages'].values()[0]['counter']
4230

Hope this helps.

Best,
Merlijn