import requests

session = requests.Session()
session.headers.update({'User-Agent': 'Tictacbot for frwiki - Owner is User:Lofhi'})
config = {
    'username': 'XXX',
    'password': 'XXX',
    'urlApi': 'https://fr.wikipedia.org/w/api.php'
}


def get_token(type_token):
    request = {
        "meta": "tokens",
        "type": type_token
    }

    result = next(query(request))

    return result


def login():
    login_token = get_token('login')['query']['tokens']['logintoken']
    request = {
        "action": "login",
        "format": "json",
        "lgname": config['username'],
        "lgpassword": config['password'],
        "lgtoken": login_token
    }

    result = session.post(config['urlApi'], data=request).json()

    if 'error' in result:
        raise Exception(result['error'])
    if 'warnings' in result:
        print(result['warnings'])
    if 'login' in result:
        print('Authentification granted')


def query(request):
    request['action'] = 'query'
    request['format'] = 'json'
    request['utf8'] = 1
    lastContinue = {}

    while True:
        # Clone original request
        req = request.copy()
        # Modify it with the values returned in the 'continue' section of the last result.
        req.update(lastContinue)
        # Call API
        result = session.get(config['urlApi'], params=req).json()

        if 'error' in result:
            raise Exception(result['error'])
        if 'warnings' in result:
            print(result['warnings'])
        if 'query' in result:
            yield result
        if 'continue' not in result:
            break

        lastContinue = result['continue']


def post(request):
    request['format'] = 'json'
    request['utf8'] = 1
    lastContinue = {}

    # Clone original request
    req = request.copy()
    # Modify it with the values returned in the 'continue' section of the last result.
    req.update(lastContinue)
    # Call API
    result = session.post(config['urlApi'], params=req).json()

    if 'error' in result:
        raise Error(result['error'])
    elif 'warnings' in result:
        print(result['warnings'])
    else:
        return result
import re
import requests

login()

params = {
    "action": "query",
    "format": "json",
    "list": "allrevisions",
    "arvprop": "comment|user|content",
    "arvlimit": "max",
    "arvnamespace": "0",
    "arvstart": "2018-04-08T22:30:00.000Z",
    "arvdir": "newer"
}
listOfArticlesUser = []
leChieur = ['fissa', "c'est bien", 'réglez moi', 'rectifié ']

for result in query(params):
    liste = result['query']['allrevisions']

    for keyResult in liste:

        for oneRevis in keyResult['revisions']:

            for unchieur in leChieur:
                
            try:
                if unchieur in oneRevis['comment'] or unchieur in oneRevis['*']:
                    print(unchieur)
                    print('[[user:' + oneRevis['user'] + ']]')
            except KeyError:
                pass
Authentification granted
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
c'est bien
[[user:Iniți]]
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
c'est bien
[[user:Benjaminm3110]]
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
c'est bien
[[user:Benjaminm3110]]
c'est bien
[[user:Benjaminm3110]]
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
c'est bien
[[user:Benjaminm3110]]
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
c'est bien
[[user:Benjaminm3110]]
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
fissa
[[user:Zergori]]
c'est bien
[[user:Zergori]]
fissa
[[user:Zergori]]
c'est bien
[[user:Zergori]]
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
c'est bien
[[user:92.91.163.98]]
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
{'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.'}, 'allrevisions': {'*': 'Because "arvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used.'}}
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-15-54b3ee6cf42e> in <module>()
     26             for unchieur in leChieur:
     27 
---> 28                 if unchieur in oneRevis['comment'] or unchieur in oneRevis['*']:
     29                     print(unchieur)
     30                     print('[[user:' + oneRevis['user'] + ']]')

KeyError: '*'