« Listepagesbot » : différence entre les versions
Aller à la navigation
Aller à la recherche
(Wikipastbot update) |
(Wikipastbot update) |
||
(3 versions intermédiaires par 2 utilisateurs non affichées) | |||
Ligne 1 : | Ligne 1 : | ||
Attention: Ajoutez la variable "<span style="color:red">uclimit</span> (correction(s): <span style="color:green"> | |||
</span>)=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 <span style="color:red">celà</span> (correction(s): <span style="color:green">delà, cela | |||
</span>) le code ne donnera qu'un faible nombre de pages modifiées récemment. | |||
== Code == | == Code == | ||
Ligne 8 : | Ligne 11 : | ||
baseurl='http://wikipast.epfl.ch/wikipast/' | baseurl='http://wikipast.epfl.ch/wikipast/' | ||
protected_logins=["Frederickaplan","Maud","Vbuntinx","Testbot | 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' | depuis_date='2017-05-02T16:00:00Z' | ||
liste_pages=[] | liste_pages=[] | ||
for user in protected_logins: | for user in protected_logins: | ||
result=requests.post(baseurl+'api.php?action=query&list=usercontribs&ucuser='+user+'&format=xml&ucend='+depuis_date) | 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') | soup=BeautifulSoup(result.content,'lxml') | ||
for primitive in soup.usercontribs.findAll('item'): | for primitive in soup.usercontribs.findAll('item'): | ||
liste_pages.append(primitive['title']) | liste_pages.append(primitive['title']) | ||
liste_pages=list(set(liste_pages)) | liste_pages=list(set(liste_pages)) |
Dernière version du 30 mai 2017 à 08:05
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)))