Jump to content
MediaWiki

API:Pageprops

From mediawiki.org
This page is a translated version of the page API:Pageprops and the translation is 100% complete.
이 문서는 MediaWiki Action API 문서의 부분입니다.
미디어위키 Action API
기본
인증
계정과 사용자
문서 운영 방법
검색
개발자 유틸리티
튜토리얼
v · d · e
미디어위키 버전:
≥ 1.17

GET 요청은 문서에 정의된 다양한 속성을 가져옵니다.

API 문서

The following documentation is the output of Special:ApiHelp/query+pageprops, automatically generated by the pre-release version of MediaWiki that is running on this site (MediaWiki.org).

prop=pageprops (pp)

(main | query | pageprops)

Get various page properties defined in the page content.

Specific parameters:
Other general parameters are available.
ppcontinue

When more results are available, use this to continue. More detailed information on how to continue queries can be found on mediawiki.org.

ppprop

Only list these page properties (action=query&list=pagepropnames returns page property names in use). Useful for checking whether pages use a certain page property.

Separate values with | or alternative.
Maximum number of values is 50 (500 for clients that are allowed higher limits).
Example:
Get properties for the pages MediaWiki and MediaWiki.
api.php?action=query&prop=pageprops&titles=MediaWiki|MediaWiki [open in sandbox]

예시

GET 요청

문서에 정의된 다양한 속성을 가져옵니다.

응답

{
"batchcomplete":"",
"query":{
"pages":{
"736":{
"pageid":736,
"ns":0,
"title":"Albert Einstein",
"pageprops":{
"defaultsort":"Einstein, Albert",
"page_image_free":"Einstein_1921_by_F_Schmutzer_-_restoration.jpg",
"wikibase-badge-Q17437798":"1",
"wikibase_item":"Q937"
}
}
}
}

샘플 코드

Python

#!/usr/bin/python3
"""
 pageprops.py
 MediaWiki API Demos
 Demo of `Pageprops` module: Get various properties defined in the page content
 MIT License
"""
importrequests
S = requests.Session()
URL = "https://en.wikipedia.org/w/api.php"
PARAMS = {
 "action": "query",
 "titles": "Albert Einstein",
 "prop": "pageprops",
 "format": "json"
}
R = S.get(url=URL, params=PARAMS)
DATA = R.json()
print(DATA)

PHP

<?php
/*
 pageprops.php
 MediaWiki API Demos
 Demo of `Pageprops` module: Get various properties defined in the page content
 MIT License
*/
$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
 "action" => "query",
 "titles" => "Albert Einstein",
 "prop" => "pageprops",
 "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 );
var_dump( $result );

JavaScript

/*
 pageprops.js
 MediaWiki API Demos
 Demo of `Pageprops` module: Get various properties defined in the page content
 MIT License
*/
varurl="https://en.wikipedia.org/w/api.php";
varparams={
action:"query",
titles:"Albert Einstein",
prop:"pageprops",
format:"json"
};
url=url+"?origin=*";
Object.keys(params).forEach(function(key){url+="&"+key+"="+params[key];});
fetch(url)
.then(function(response){returnresponse.json();})
.then(function(response){console.log(response);})
.catch(function(error){console.log(error);});

MediaWiki JS

/*
	pageprops.js
	MediaWiki API Demos
	Demo of `Pageprops` module: Get various properties defined in the page content
	MIT License
*/
varparams={
action:'query',
titles:'Albert Einstein',
prop:'pageprops',
format:'json'
};
varapi=newmw.Api();
api.get(params).then(function(data){
console.log(data);
});

같이 보기

  • API:pageswithprop – 주어진 문서 속성을 사용하여 모든 문서를 나열합니다.
  • API:pagepropnames – 위키에서 사용중인 모든 문서 속성 이름을 나열합니다.
  • API:properties – 문서의 일반적인 속성을 가져옵니다 (페이지 콘텐츠에서 반드시 정의되는 것은 아닙니다).

AltStyle によって変換されたページ (->オリジナル) /