User:Dgihmvks/Sandbox5

维基百科,自由的百科全书
#!/usr/bin/python
# -*- coding: utf-8  -*-
import os
import sys,time
import wikipedia, config
site=wikipedia.getSite()

n=0
titles=[]
templates=[u'VfD',u'Stub',u'stub',u'vfd', u'vfd-s',  u'Vfd-s',u'Vfd-b',u'vfd-b',u'afD',u'AfD',u'Unreferenced',u'unreferenced',u'Delete',u'delete',u'Cleanup',u'cleanup',u'Uncategorized',u'uncategorized',u'Notability',u'notability',u'wikify',u'Wikify',u'translating',u'Translating',u'Copyvio',u'copyvio',u'notchinese',u'Notchinese', u'notchinesetitle', u'Notchinesetitle',u'Original research', u'fact', u'Fact',u'disambig',u'Disambig',u'Copyedit translation',u'roughTranslation',u'RoughTranslation',u'Cleanup-rewrite',u'importance',u'Importance',u'review',u'Review',u'howto',u'Howto',u'copyedit',u'Copyedit',u'disputed',u'Disputed',u'Globalize',u'Inappropriate tone', u'Split',u'Merge',u'Mergefrom',u'Mergeto',u'矛盾',u'Weasel',u'POV',u'TotallyDisputed',u'Hoax',u'inuse',u'Inuse', u'Attention']
def dyk(page, length, username,date):
    global n
    title=page.title()
    for template in templates:
        if template in page.templates():
            wikipedia.output(u'Found in [[%s]](%s byte): "{{%s}}" in content, nothing necessary' % (title, str(length), template))
            return
    ndyk=u'{{NDYK|title='+title+u'|length='+str(length)+u'|user='+username+u'|date='+date+u'}}\n'
    n=n+1
#    dyks=title+u' 长度:'+str(length)+u'\n'
    titles.append(ndyk)
    wikipedia.output(u'Fond a DYK: [[%s]]. length is %s byte' % (title, str(length)))
while True:

    for (page, date, length, loggedIn, username, comment) in site.newpages(500):
#    n=n+1
#    while True:
#       page = wikipedia.Page(wikipedia.getSite(), p)
        
#        t=len(text)
        if length >= 3000:
            dyk(page, length, username, date)
    dyk=wikipedia.Page(site,u'User:Sz-iwbot/DYK')
    dykpage=''.join(titles)
    h=u'最新创建的500个条目中共有%s个条目“可能”符合[[WP:DYKC|DYKC]]的条件。本列表最后更新于~~~~~\n' %str(n)
    h=h+u'{|class="wikitable"\n!条目||长度||创建者||创建日期\n'
    dykpage=h+dykpage
    dyk.put(dykpage,u'BOT找到%s个条目' %str(n))
    time.sleep(60*60)
    n=0
#    else:
#        print '%s is OK: %s words' % (page, length)
#        time.sleep(5*60*60)    
#    raise