« Programmation Python/Programmer en deux minutes/l'interface de Wikipédia pour programmer » : différence entre les versions

Contenu supprimé Contenu ajouté
mAucun résumé des modifications
DannyS712 (discussion | contributions)
m <source> -> <syntaxhighlight> (phab:T237267)
Ligne 18 :
|p3=rvprop=timestamp
|p4=titles=Accueil
|result=<sourcesyntaxhighlight lang="xml"><?xml version="1.0"?>
<?xml version="1.0"?>
<api>
Ligne 31 :
</query>
</api>
</sourcesyntaxhighlight>}}
 
À l'écriture de ces lignes le 17 mai 2009, le dernier réviseur de la page [[Accueil]] était {{u|Savant-fou}} - cette information est contenue dans la chaîne « user="Savant-fou" » - qui, le 25 avril 2009 à 16:07, a résumé sa modification par le commentaire « Ajout rapide de la catégorie [[:Catégorie:Accueil|Accueil]] (avec [[MediaWiki:Gadget-HotCats.js|HotCats]]) ». Pour connaître le dernier réviseur de la page d'accueil en ce moment, cliquez sur le lien ci-dessus qui affiche ce [//fr.wikibooks.org/w/api.php?action=query&prop=info|revisions&titles=Accueil&format=xml document XML].
Ligne 42 :
| p3=prop=info
| p4=format=xmlfm
| result=<sourcesyntaxhighlight lang="xml">
<?xml version="1.0" encoding="utf-8"?>
<api>
Ligne 51 :
</query>
</api>
</syntaxhighlight>
</source>
}}
{{ApiEx
Ligne 59 :
| p3=prop=info
| p4=format=jsonfm
| result=<sourcesyntaxhighlight lang="javascript">
{
"query": {
Ligne 75 :
}
}
</syntaxhighlight>
</source>
}}
{{ApiEx
Ligne 83 :
| p3=prop=info
| p4=format=yamlfm
| result=<sourcesyntaxhighlight lang="text">
---
query:
Ligne 96 :
counter: 4698
length: 81076
</syntaxhighlight>
</source>
}}
{{ApiEx
Ligne 104 :
| p3=prop=info
| p4=format=wddxfm
| result=<sourcesyntaxhighlight lang="xml">
<?xml version="1.0" encoding="utf-8"?>
<wddxPacket version="1.0">
Ligne 146 :
</data>
</wddxPacket>
</syntaxhighlight>
</source>
}}
{{ApiEx
Ligne 154 :
| p3=prop=info
| p4=format=php
| result=<sourcesyntaxhighlight lang="text">
a:1:{s:5:"query";a:1:{s:5:"pages";a:1:{i:736;a:7:{s:6:"pageid";i:736;s:2:"ns";i:0;s:5:"title";s:15:"Albert Einstein";
s:7:"touched";s:20:"2007-07-06T04:37:30Z";s:9:"lastrevid";i:142335140;s:7:"counter";i:4698;s:6:"length";i:86906;}}}}</sourcesyntaxhighlight>
}}
{{ApiEx
Ligne 164 :
| p3=prop=info
| p4=format=dbg
| result=<sourcesyntaxhighlight lang="text">
array (
'query' =>
Ligne 183 :
),
)
</syntaxhighlight>
</source>
}}
{{boîte déroulante fin}}
Ligne 192 :
{|width=70% align=center
|{{boîte déroulante début|titre=modifieur_de_la_page.py}}
<sourcesyntaxhighlight lang=python>
#!/usr/bin/python
# -*- coding: latin-1 -*-
Ligne 214 :
reviseur = re.findall(' user="(.*?)" ',infos) # recherche l'expression rationnelle
print("\nDernier reviseur : " + reviseur) # Rajoutez des parenthèses pour Python 3 !
</syntaxhighlight>
</source>
{{boîte déroulante fin}}
|}
Ligne 226 :
{|width=70% align=center
|{{boîte déroulante début|titre= boucle_reviseur_bistro.py}}
<sourcesyntaxhighlight lang=python>
#!/usr/bin/python
# -*- coding: latin-1 -*-
Ligne 248 :
for chacun in reviseur:
print("\nDernier reviseur du bistro du " + b + " avril 2009 : " + chacun)
</syntaxhighlight>
</source>
{{boîte déroulante fin}}
|}
Ligne 257 :
{|width=70% align=center
|{{boîte déroulante début|titre=liste_des_reviseurs.py}}
<sourcesyntaxhighlight lang=python>
#!/usr/bin/python
# -*- coding: latin-1 -*-
Ligne 283 :
for comment in commentaire:
print("\nCommentaire de revision : " + comment)
</syntaxhighlight>
</source>
{{boîte déroulante fin}}
|}
Ligne 294 :
{|width=70% align=center
|{{boîte déroulante début|titre=[http://svn.wikimedia.org/viewvc/pywikipedia/trunk/pywikipedia/statistics_in_wikitable.py?view=markup <code>statistics_in_wikitable.py</code>]}}
<sourcesyntaxhighlight lang=python>
#!/usr/bin/python
# -*- coding: utf-8 -*-
Ligne 463 :
wikipedia.stopme()
 
</syntaxhighlight>
</source>
{{boîte déroulante fin}}
|}