跳转到内容

User:MPpbot/code

维基百科,自由的百科全书
# -*- coding: utf-8  -*-

import os, sys
import wikipedia, catlib, query
mysite = wikipedia.getSite()
mainpagetitle=u"Wikipedia:首页"
mainpage=wikipedia.Page(mysite,mainpagetitle)
params = {
    'action'    :'query',
    'prop'      :'links',
    'titles'    :mainpagetitle,
    'plnamespace': '0',
    'pllimit':  500
    }    
pages = query.GetData(params, encodeTitle = False)['query']['pages'].values()[0]['links']

#pagelist=mainpage.getReferences(follow_redirects=True, withTemplateInclusion=False)

#pages = [page for page in mainpage.getReferences(follow_redirects=True, withTemplateInclusion=False)]

for page in pages:
    p=wikipedia.Page(mysite,page['title'])
    if p.protection() == []:
        p.protect(editcreate = 'autoconfirmed', move = 'autoconfirmed', reason = '[[WP:BOTVAND]]', editcreate_duration = '1 day',
                move_duration = '1 day', cascading = False, prompt = False, throttle = True)