import pywikibot
import requests
import re
import re

regex = r"(\[\[Chrétiens d'Orient\|Églises d'Orient\]\])"

headers = {
    'User-Agent': 'User:Tictacbot - frwiki'
}

data = {
	"action": "query",
	"format": "json",
	"list": "search",
	"srsearch": "insource:\"[[Chrétiens d'Orient|Églises d'orient]]\"",
	"srnamespace": "0",
	"srlimit": "100",
	"srwhat": "text",
	"srinfo": "totalhits",
	"srprop": "",
	"srsort": "just_match"
}

site = pywikibot.Site('fr', 'wikipedia')

with requests.Session() as r:
    r = requests.post("https://fr.wikipedia.org/w/api.php", headers=headers, data=data)
    result = r.json()
    
for article in result["query"]["search"]:
    title = article["title"]
    page = pywikibot.Page(site, title)
    texte = page.get()
    texte = re.sub(regex, "[[Christianisme oriental|Églises d'Orient]]", texte, 0, re.MULTILINE | re.IGNORECASE)
    
    page.text = texte
    page.save(summary="[[wp:bot|robot]] : requête aux bots - confusion entre Chrétiens d'Orient et christianisme oriental")
Page [[fr:Fêtes mobiles dans le rite romain]] saved
Sleeping for 9.5 seconds, 2018-10-28 13:00:32
Page [[fr:Dimanche des Reliques]] saved
Sleeping for 9.3 seconds, 2018-10-28 13:00:42
Page [[fr:Prothèse (liturgie)]] saved
Sleeping for 6.5 seconds, 2018-10-28 13:00:55
Page [[fr:Astérisque (liturgie)]] saved
Sleeping for 9.3 seconds, 2018-10-28 13:01:02
Page [[fr:Service mémoriel (rite byzantin)]] saved
Sleeping for 9.2 seconds, 2018-10-28 13:01:12
Page [[fr:Mardarius (martyr)]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:01:22
Page [[fr:Heures royales]] saved
Sleeping for 9.3 seconds, 2018-10-28 13:01:32
Page [[fr:Mercredi de mi-Pentecôte]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:01:42
Page [[fr:Table de prothèse]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:01:52
Page [[fr:Homélie pascale de Jean Chrysostome]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:02:02
Page [[fr:Typika]] saved
Sleeping for 9.3 seconds, 2018-10-28 13:02:12
Page [[fr:Synaxaire]] saved
Sleeping for 9.1 seconds, 2018-10-28 13:02:23
Page [[fr:Diskos]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:02:32
Page [[fr:Liturgie des Saints Dons présanctifiés]] saved
Sleeping for 9.2 seconds, 2018-10-28 13:02:42
Page [[fr:Semaine de la viande]] saved
Sleeping for 9.5 seconds, 2018-10-28 13:02:52
Page [[fr:Polyéléos]] saved
Sleeping for 9.5 seconds, 2018-10-28 13:03:02
Page [[fr:Épimanikia]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:03:12
Page [[fr:Petit carême]] saved
Sleeping for 9.5 seconds, 2018-10-28 13:03:22
Page [[fr:Aër]] saved
Sleeping for 9.5 seconds, 2018-10-28 13:03:32
Page [[fr:Dimanche du Pardon]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:03:42
Page [[fr:Vendredi veille de Lazare]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:03:52
Page [[fr:Dimanche du Paralytique]] saved
Sleeping for 9.5 seconds, 2018-10-28 13:04:02
Page [[fr:Paramonie]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:04:12
Page [[fr:Dimanche de tous les Saints]] saved
Sleeping for 9.3 seconds, 2018-10-28 13:04:22
Page [[fr:Triodion]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:04:32
Page [[fr:Anaphore (liturgie)]] saved
Sleeping for 9.3 seconds, 2018-10-28 13:04:42
Page [[fr:Petites Heures]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:04:52
Page [[fr:Mémoire éternelle (chant liturgique)]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:05:02
Page [[fr:Artos (homonymie)]] saved
Sleeping for 9.5 seconds, 2018-10-28 13:05:12
Page [[fr:Theotokion]] saved
Sleeping for 9.2 seconds, 2018-10-28 13:05:23
Page [[fr:Cherubikon]] saved
Sleeping for 9.1 seconds, 2018-10-28 13:05:33
Page [[fr:Jeûne de la Nativité]] saved
Sleeping for 9.2 seconds, 2018-10-28 13:05:43
Page [[fr:Cuiller (liturgie)]] saved
Sleeping for 9.3 seconds, 2018-10-28 13:05:53
Page [[fr:Aër (liturgie)]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:06:02
Page [[fr:Ikos]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:06:12
Page [[fr:Épitrachelion]] saved
Sleeping for 9.3 seconds, 2018-10-28 13:06:22
Page [[fr:Heures pascales]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:06:32
Page [[fr:Dimanche de Jean Climaque]] saved
Sleeping for 9.3 seconds, 2018-10-28 13:06:42
Page [[fr:Dimanche des Saints Pères]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:06:52
Page [[fr:Trikirion pascal]] saved
Sleeping for 9.3 seconds, 2018-10-28 13:07:03
Page [[fr:Calendrier des saints]] saved
Sleeping for 9.2 seconds, 2018-10-28 13:07:13
Page [[fr:Dimanche de Marie l'Égyptienne]] saved
Sleeping for 9.0 seconds, 2018-10-28 13:07:23
Page [[fr:Noms traditionnels d'anonymes bibliques]] saved
Sleeping for 8.8 seconds, 2018-10-28 13:07:33
Page [[fr:Doxastikon]] saved
Sleeping for 9.3 seconds, 2018-10-28 13:07:43
Page [[fr:Artos]] saved
Sleeping for 9.1 seconds, 2018-10-28 13:07:53
Page [[fr:Exapostilarion]] saved
Sleeping for 9.3 seconds, 2018-10-28 13:08:03
Page [[fr:Rituel orthodoxe]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:08:12
Page [[fr:Canonarque]] saved
Sleeping for 9.5 seconds, 2018-10-28 13:08:22
Page [[fr:Apolytikon]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:08:33
Page [[fr:Hypakoë]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:08:43
Page [[fr:Dimanche du Pharisien et du Publicain]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:08:53
Page [[fr:Theotokarion]] saved
Sleeping for 9.5 seconds, 2018-10-28 13:09:03
Page [[fr:Kathisma]] saved
Sleeping for 9.2 seconds, 2018-10-28 13:09:13
Page [[fr:Tropaire pascal]] saved
Sleeping for 9.3 seconds, 2018-10-28 13:09:23
Page [[fr:Dimanche de l'Orthodoxie]] saved
Sleeping for 9.3 seconds, 2018-10-28 13:09:33
Page [[fr:Panikhide]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:09:43
Page [[fr:Semaine radieuse]] saved
Sleeping for 9.3 seconds, 2018-10-28 13:09:53
Page [[fr:Pentecostarion]] saved
Sleeping for 9.2 seconds, 2018-10-28 13:10:03
Page [[fr:Dimanche de Thomas]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:10:13
Page [[fr:Dimanche de la Samaritaine]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:10:23
Page [[fr:Samedi des défunts]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:10:33
Page [[fr:Litia]] saved
Sleeping for 9.5 seconds, 2018-10-28 13:10:43
Page [[fr:Catabase]] saved
Sleeping for 9.5 seconds, 2018-10-28 13:10:53
Page [[fr:Liturgie de la Préparation]] saved
Sleeping for 9.3 seconds, 2018-10-28 13:11:03
Page [[fr:Mégalynarion]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:11:13
Page [[fr:Irmologion]] saved
Sleeping for 9.2 seconds, 2018-10-28 13:11:23
Page [[fr:Apostiche]] saved
Sleeping for 9.0 seconds, 2018-10-28 13:11:33
Page [[fr:Theos Kyrios]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:11:43
Page [[fr:Prokeimenon]] saved
Sleeping for 9.2 seconds, 2018-10-28 13:11:53
Page [[fr:Vigiles nocturnes]] saved
Sleeping for 9.2 seconds, 2018-10-28 13:12:03
Page [[fr:Samedi de Lazare]] saved
Sleeping for 9.2 seconds, 2018-10-28 13:12:13
Page [[fr:Agneau (liturgie)]] saved
Sleeping for 9.3 seconds, 2018-10-28 13:12:23
Page [[fr:Stase]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:12:33
Page [[fr:Grand Canon d'André de Crète]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:12:43
Page [[fr:Orthros (liturgie)]] saved
Sleeping for 9.3 seconds, 2018-10-28 13:12:53
Page [[fr:Fêtes mobiles dans le rite byzantin]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:13:03
Page [[fr:Psaltikon]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:13:13
Page [[fr:Polychronion]] saved
Sleeping for 9.3 seconds, 2018-10-28 13:13:23
Page [[fr:Menaion]] saved
Sleeping for 9.3 seconds, 2018-10-28 13:13:33
Page [[fr:Dimanche de l'Aveugle-né]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:13:43
Page [[fr:Canon eucharistique]] saved
Sleeping for 9.4 seconds, 2018-10-28 13:13:53
Page [[fr:L'Échelle sainte]] saved
Sleeping for 9.2 seconds, 2018-10-28 13:14:03
Page [[fr:Litia (Vêpres orthodoxes)]] saved
Sleeping for 9.3 seconds, 2018-10-28 13:14:13
Page [[fr:Typikon]] saved