Listepagesbot

De Wikipast
Version datée du 30 mai 2017 à 08:05 par Orthobot (discussion | contributions) (Wikipastbot update)
(diff) ← Version précédente | Voir la version actuelle (diff) | Version suivante → (diff)
Aller à la navigation Aller à la recherche

Attention: Ajoutez la variable "uclimit (correction(s): )=500" afin d'avoir une liste plus complète des pages récentes. En effet, cette variable est fixée à 10 par défaut et sans celà (correction(s): delà, cela ) le code ne donnera qu'un faible nombre de pages modifiées récemment.

Code

# -*- coding: utf-8 -*-

import requests
from bs4 import BeautifulSoup
baseurl='http://wikipast.epfl.ch/wikipast/'

protected_logins=["Frederickaplan","Maud","Vbuntinx","Testbot","IB","SourceBot","PageUpdaterBot","Orthobot","BioPathBot","ChronoBOT","InferenceBot","Amonbaro","AntoineL","AntoniasBanderos","Arnau","Arnaudpannatier","Aureliver","Brunowicht","Burgerpop","Cedricviaccoz","Christophe","Claudioloureiro","Ghislain","Gregoire3245","Hirtg","Houssm","Icebaker","JenniCin","JiggyQ","JulienB","Kl","Kperrard","Leandro Kieliger","Marcus","Martin","MatteoGiorla","Mireille","Mj2905","Musluoglucem","Nacho","Nameless","Nawel","O'showa","PA","Qantik","QuentinB","Raphael.barman","Roblan11","Romain Fournier","Sbaaa","Snus","Sonia","Tboyer","Thierry","Titi","Vlaedr","Wanda"]
depuis_date='2017-05-02T16:00:00Z'

liste_pages=[]
for user in protected_logins:
    result=requests.post(baseurl+'api.php?action=query&list=usercontribs&ucuser='+user+'&format=xml&ucend='+depuis_date+'&<span style="color:red">uclimit</span> (correction(s): <span style="color:green">
</span>)=500')
    soup=BeautifulSoup(result.content,'lxml')
    for primitive in soup.usercontribs.findAll('item'):
        liste_pages.append(primitive['title'])

liste_pages=list(set(liste_pages))
for page in liste_pages:
    print(page)
print('longueur: '+str(len(liste_pages)))