واجهة برمجة التطبيقات:Querypage

This page is a translated version of the page API:Querypage and the translation is 100% complete.
إصدار ميدياويكي:
1.18

طلب GET الغرض منه الحصول على قائمة تقدمها صفحة خاصة تستند إلى QueryPage.

توثيق واجهة برمجة التطبيقات


list=querypage (qp)

(main | query | querypage)
  • This module requires read rights.
  • This module can be used as a generator.
  • Source: MediaWiki
  • License: GPL-2.0-or-later

Get a list provided by a QueryPage-based special page.

Specific parameters:
Other general parameters are available.
qppage

The name of the special page. Note, this is case-sensitive.

This parameter is required.
One of the following values: Ancientpages, BrokenRedirects, Deadendpages, DisambiguationPageLinks, DisambiguationPages, DoubleRedirects, Fewestrevisions, GadgetUsage, GloballyWantedFiles, ListDuplicatedFiles, Listredirects, Lonelypages, Longpages, MediaStatistics, MostGloballyLinkedFiles, Mostcategories, Mostimages, Mostinterwikis, Mostlinked, Mostlinkedcategories, Mostlinkedtemplates, Mostrevisions, OrphanedTimedText, Shortpages, Uncategorizedcategories, Uncategorizedimages, Uncategorizedpages, Uncategorizedtemplates, UnconnectedPages, Unusedcategories, Unusedimages, Unusedtemplates, Unwatchedpages, Wantedcategories, Wantedfiles, Wantedpages, Wantedtemplates, Withoutinterwiki
qpoffset

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

Type: integer
Default: 0
qplimit

Number of results to return.

Type: integer or max
The value must be between 1 and 500.
Default: 10

مثال

طلب GET

في الاستعلام التالي نستدعي واجهة برمجة التطبيقات كي نحصل على قائمة بأول عشر صفحات غير مصنفة


النتيجة

{
  "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"
        }
        ...
      ]
    }
  }
}

عينة من الكود البرمجي

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 );
	}
} );

قيم الصفحة الخاصة

(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

الأخطاء المحتملة

الكود معلومات
unknown_qppage قيمة غير معروفة للوسيط qppage: value.
noqppage يجب تعيين الوسيط qppage.

ملاحظات إضافية

  • يمكن استخدام هذه الوحدة البرمجية بصفة مولّد .
  • ترشيح نطاقات الاسم غير متاح على هذه الصفحات. الطريقة الممكنة هي ترشيح «ns» يدويًا من النتائج المجمّعة.

انظر أيضا