import pywikibot
import re
from pywikibot import pagegenerators
site = pywikibot.Site()
linkpage= pywikibot.Page(site,"User:PearBOT/linkpage")
cat = pywikibot.Category(site,'Category:Living people')
gen = pagegenerators.LinkedPageGenerator(linkpage)
for page in gen:
    text = page.text
    template = re.search("{{\s?10years\s?\|[^\|}]*\|([^\|}]*)\|([^\|}]*)",text)
    if template:
        if not re.search(template.group(1)+" "+template.group(2),page.title,page):
            print(page)
    else:
        print(page)
[[en:User:Pascal666/cats/22]]
[[en:User:Pascal666/cats/31]]
[[en:Template:10years]]
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-10-4b5ecb142826> in <module>
     10     template = re.search("{{\s?10years\s?\|[^\|}]*\|([^\|}]*)\|([^\|}]*)",text)
     11     if template:
---> 12         if not re.search(template.group(1)+" "+template.group(2),page.title,page):
     13             print(page)
     14     else:

/usr/lib/python3.6/re.py in search(pattern, string, flags)
    180     """Scan through string looking for a match to the pattern, returning
    181     a match object, or None if no match was found."""
--> 182     return _compile(pattern, flags).search(string)
    183 
    184 def sub(pattern, repl, string, count=0, flags=0):

/usr/lib/python3.6/re.py in _compile(pattern, flags)
    299     if not sre_compile.isstring(pattern):
    300         raise TypeError("first argument must be string or compiled pattern")
--> 301     p = sre_compile.compile(pattern, flags)
    302     if not (flags & DEBUG):
    303         if len(_cache) >= _MAXCACHE:

/usr/lib/python3.6/sre_compile.py in compile(p, flags)
    560     if isstring(p):
    561         pattern = p
--> 562         p = sre_parse.parse(p, flags)
    563     else:
    564         pattern = None

/usr/lib/python3.6/sre_parse.py in parse(str, flags, pattern)
    853 
    854     try:
--> 855         p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
    856     except Verbose:
    857         # the VERBOSE flag was switched on inside the pattern.  to be

TypeError: unsupported operand type(s) for &: 'Category' and 'int'