API:Querypage/fr
Appearance
Cette page fait partie de la documentation de l'API MediaWiki Action. |
Version de MediaWiki : | ≥ 1.18 |
GET request to get a list provided by a QueryPage-based special page.
Documentation de l'API
Exemple
Requête GET
In the below query, we call the API to get a list of the first ten pages which are uncategorized
Réponse
{
"batchcomplete": "",
"continue": {
"continue": "-||",
"qpoffset": 10
},
"query": {
"querypage": {
"cached": "",
"cachedtimestamp": "2019-02-22T11:46:48Z",
"maxresults": 5000,
"name": "Uncategorizedpages",
"results": [
{
"ns": 0,
"title": "Abelardo Delgado",
"value": "0"
},
{
"ns": 0,
"title": "Agriculture in Tonga",
"value": "0"
},
{
"ns": 0,
"title": "Andriandramaka",
"value": "0"
}
...
]
}
}
}
Exemple de code
Python
#!/usr/bin/python3
"""
get_querypage_list.py
MediaWiki API Demos
Demo of `Querypage` module: List first 10 pages which are uncategorized
MIT License
"""
import requests
S = requests.Session()
URL = "https://en.wikipedia.org/w/api.php"
PARAMS = {
"qplimit": "10",
"action": "query",
"qppage": "Uncategorizedpages",
"list": "querypage",
"format": "json"
}
R = S.get(url=URL, params=PARAMS)
DATA = R.json()
QUERYPAGE = DATA['query']['querypage']['results']
for p in QUERYPAGE:
print(str(p['title']))
PHP
<?php
/*
get_querypage_list.php
MediaWiki API Demos
Demo of `Querypage` module: List first 10 pages which are uncategorized
MIT License
*/
$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
"action" => "query",
"list" => "querypage",
"qppage" => "Uncategorizedpages",
"qplimit" => "10",
"format" => "json"
];
$url = $endPoint . "?" . http_build_query( $params );
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$output = curl_exec( $ch );
curl_close( $ch );
$result = json_decode( $output, true );
foreach( $result["query"]["querypage"]["results"] as $page ){
echo( $page["title"] . "\n" );
}
JavaScript
/*
get_querypage_list.js
MediaWiki API Demos
Demo of `Querypage` module: List first 10 pages which are uncategorized
MIT License
*/
var url = "https://en.wikipedia.org/w/api.php";
var params = {
action: "query",
list: "querypage",
qppage: "Uncategorizedpages",
qplimit: "10",
format: "json"
};
url = url + "?origin=*";
Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];});
fetch(url)
.then(function(response){return response.json();})
.then(function(response) {
var querypage = response.query.querypage.results;
for (var p in querypage) {
console.log(querypage[p].title);
}
})
.catch(function(error){console.log(error);});
MediaWiki JS
/*
get_querypage_list.js
MediaWiki API Demos
Demo of `Querypage` module: List first 10 pages which are uncategorized
MIT License
*/
var params = {
action: 'query',
list: 'querypage',
qppage: 'Uncategorizedpages',
qplimit: '10',
format: 'json'
},
api = new mw.Api();
api.get( params ).done( function ( data ) {
var querypage = data.query.querypage.results,
p;
for ( p in querypage ) {
console.log( querypage[ p ].title );
}
} );
Valeurs de pages spéciales
(MediaWiki 1.32.0)
Ancientpages | Listredirects | Mostlinked | Unusedtemplates |
BrokenRedirects | Lonelypages | Mostrevisions | Unwatchedpages |
Deadendpages | Longpages | Shortpages | Wantedcategories |
DisambiguationPageLinks | MediaStatistics | Uncategorizedcategories | Wantedfiles |
DisambiguationPages | Mostcategories | Uncategorizedpages | Wantedpages |
DoubleRedirects | MostGloballyLinkedFiles | Uncategorizedimages | Wantedtemplates |
EntityUsage | Mostimages | Uncategorizedtemplates | Withoutinterwiki |
Fewestrevisions | Mostinterwikis | UnconnectedPages | |
GloballyWantedFiles | Mostlinkedcategories | Unusedcategories | |
ListDuplicatedFiles | Mostlinkedtemplates | Unusedimages |
Erreurs possibles
Code | Info |
---|---|
unknown_qppage | Valeur non reconnue du paramètre qppage: value. |
noqppage | Le paramètre qppage doit être défini. |
Notes supplémentaires
- This module can be used as a generator .
- Namespace filtering is unavailable on these pages.
The possible way is to manually filter "ns" from collected results.
Voir aussi
- API:Allpages/fr - Lists all pages fitting certain criteria, within a given Espace de noms .
- API:Categorymembers/fr - Lists all pages within a category
- API:Pageswithprop/fr - List all pages using a given page property.