Jump to content

User:Ritchie333/unlinkedblps.py

From Wikipedia, the free encyclopedia
#!/usr/bin/python

import re
import pywikibot
from pywikibot import pagegenerators

name = 'Category:All unreferenced BLPs'
reLinks = re.compile( '==.*External links.*==' )

count = 0
site = pywikibot.Site()
cat = pywikibot.Category( site, name )
gen = pagegenerators.CategorizedPageGenerator( cat )
for page in gen:
    title = page.title( False, False )
    text = page.text
    match = reLinks.search( text )
    if( match is None ):
        print( '* [[' + title + ']]' )
        count += 1
print( '<small>( ' + str( count ) + ' entries )</small>' )