import pywikibot as pw
import re as re
site = pw.Site('fr', 'wikipedia')
regex = '\| superficie  = [0-9]+.[0-9]+'
count = 0
#print (pw.site.APISite.allpages())
print(pw.Category(site, 'Catégorie:Portail:Luxembourg/Articles_liés'))

member = pw.Category(site, 'Catégorie:Portail:Luxembourg/Articles_liés').members(namespaces = [0])
for page in member:
    #print (page)    
    old_text = page.text
    #print (page.title())
    #print (pw.textlib.extract_templates_and_params_regex_simple( old_text))
    match = re.search(r'\| superficie  = [0-9]+.[0-9]+', old_text)
    if match:
        textRemove = match.group()
        print (textRemove)        
        new_text = old_text.replace(textRemove, '')
        new_text = new_text.replace('\n\n', '\n',1)
        #print (new_text)
        page.text = new_text
        page.save(u"Wikipédia:Bot/Requêtes/2018/05-Rbot:champs superficie inutile dans infobox")
        count = count + 1
        print (count)
        #extract pages templates
        #template = pw.textlib.extract_templates_and_params_regex_simple( old_text)
        #print (template)