I have currently written this block of code in which the correct number of bots is returned, but upon checking with the https://xtools.wmcloud.org/articleinfo/en.wikipedia.org/Planet_of_the_Apes?botlimit=100#auto-edits page. I can see the bots with '(Former Bot)' after their name are not getting included in the final number. Is there a way to check for these in a general case so the code can also be used on other articles?
I was expecting to get a total of 31 users and actually got 24.
site = pywikibot.Site("en", "wikipedia")
page = pywikibot.Page(site, 'Planet_of_the_Apes')
revisions_initial = page.revisions()
revisions = list(revisions_initial)
bot_contributors_list = []
bot_edits = 0
for Revision in revisions:
if Revision.anon == False:
user_check = Revision.user.replace(" ", "_")
response = requests.get(
'https://en.wikipedia.org/w/api.phpaction=query&list=users&ususers=' + user_check + '&usprop=groups&format=json').text
response_info = json.loads(response)
if 'bot' in response_info['query']['users'][0]['groups']:
bot_contributors_list.append(user_check)
bot_edits = bot_edits + 1
bot_contributors_set = set(bot_contributors_list)