跳转到内容

用户:Makecat/autopatrol.py

维基百科,自由的百科全书
# /usr/bin/python
# -*- coding: utf-8  -*-
import wikipedia
import pagegenerators

site = wikipedia.getSite()
site.forceLogin()
gen = site.newpages
 
# Note: see https://sourceforge.net/tracker/?func=detail&aid=3586068&group_id=93107&atid=603140

print 'Querying for pages that can be patrolled...'

for (page) in site.newpages(number = 100, namespace = 0, repeat = True, rcshow = ['!bot', '!redirect', '!patrolled'], returndict = True):
    catnamelist = ''
    for catobj in page[0].categories(): # it is <class 'catlib.Category'>
        catnamelist += catobj.title() + '\n'
    #print page[0].title(), catnamelist
    if (u'快速删除候选' in catnamelist) or (u'怀疑侵犯版权页面‎' in catnamelist) or (u'条目删除候选' in catnamelist):
        print u'Patrolling', page[0].title()
        rcid = page[1]['rcid']
        site.patrol(rcid)
        print 'Has marked as patrol, for %s' % page[0].title()
    else:
        print 'The article can not be automatically patrolled by a bot.'
print 'Done!'