Jump to content

User:Ritchie333/unlinkedblps.py

From Wikipedia, the free encyclopedia

This is the current revision of this page, as edited by Qwerfjkl (bot) (talk | contribs) at 17:47, 8 May 2022 (→‎top: Replaced deprecated <source> tags with <syntaxhighlight>). The present address (URL) is a permanent link to this version.

(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
#!/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>' )