API:Duplicatefiles
本页是MediaWiki Action API帮助文档的一部份。 |
GET request to get a list of duplicates of the given file.
MediaWiki版本: | ≥ 1.14 |
API帮助文档
示例
GET请求
List duplicates of two images.
回应
{
"batchcomplete": "",
"query": {
"normalized": [
{
"from": "Image:1995.jpg",
"to": "File:1995.jpg"
},
{
"from": "Image:Welcome.gif",
"to": "File:Welcome.gif"
}
]
...
}
}
}
}
示例代码
Python
#!/usr/bin/python3
"""
duplicate_files.py
MediaWiki API Demos
Demo of `Duplicatefiles` module: List duplicates of the given files.
MIT License
"""
import requests
S = requests.Session()
URL = "https://en.wikipedia.org/w/api.php"
PARAMS = {
"action": "query",
"titles": "Image:1995.jpg|Image:Welcome.gif",
"prop": "duplicatefiles",
"format": "json"
}
R = S.get(url=URL, params=PARAMS)
DATA = R.json()
print(DATA)
PHP
<?php
/*
duplicate_files.php
MediaWiki API Demos
Demo of `Duplicatefiles` module: List duplicates of the given files.
MIT License
*/
$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
"action" => "query",
"titles" => "Image:1995.jpg|Image:Welcome.gif",
"prop" => "duplicatefiles",
"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 );
echo( $output );
JavaScript
/*
duplicate_files.js
MediaWiki API Demos
Demo of `Duplicatefiles` module: List duplicates of the given files.
MIT License
*/
var url = "https://en.wikipedia.org/w/api.php";
var params = {
action: "query",
titles: "Image:1995.jpg|Image:Welcome.gif",
prop: "duplicatefiles",
format: "json"
};
request.get({ url: url, qs: params }, function(error, res, body) {
if (error) {
return;
}
console.log(body);
});
MediaWiki JS
/*
duplicate_files.js
MediaWiki API Demos
Demo of `Duplicatefiles` module: List duplicates of the given files.
MIT License
*/
var params = {
action: "query",
titles: "Image:1995.jpg|Image:Welcome.gif",
prop: "duplicatefiles",
format: "json"
},
api = new mw.Api();
api.get( params ).done( function ( data ) {
console.log( data );
} );
参数历史
- v1.20: 啟用
dfdir
,dflocalonly
參見
- API:Fileinfo - to supersede this
prop
in future versions of the MediaWiki Action API. - API:存储图片信息 - retrieves information about stashed images.
- API:Images - retrieves all images embedded on a page.
- API:Info - retrieves basic information about a list of pages.
- API:Imageusage - finds all pages that use the given image or images.
- API:Imageinfo - retrieves information about an image file or files.