API:Backlinks/ar
![]() | هذه الصفحة جزء من توثيق واجهة برمجة تطبيقات ميدياويكي التي تحمل اسم Action. |
إصدار ميدياويكي: | ≥ 1.9 |
طلب GET يسرد كافة الصفحات التي تصل شبكيًا إلى صفحة محددة.
توثيق واجهة برمجة التطبيقات
![]() | أعمال التوثيق التالية هي نتاج صفحة Special: |
list=backlinks (bl)
- This module requires read rights.
- This module can be used as a generator.
- Source: MediaWiki
- License: GPL-2.0-or-later
Find all pages that link to the given page.
- bltitle
Title to search. Cannot be used together with blpageid.
- blpageid
Page ID to search. Cannot be used together with bltitle.
- Type: integer
- blcontinue
When more results are available, use this to continue. More detailed information on how to continue queries can be found on mediawiki.org.
- blnamespace
The namespace to enumerate.
- Values (separate with | or alternative): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 90, 91, 92, 93, 100, 101, 102, 103, 104, 105, 106, 107, 710, 711, 828, 829, 1198, 1199, 2600, 5500, 5501
- To specify all values, use *.
- bldir
The direction in which to list.
- One of the following values: ascending, descending
- Default: ascending
- blfilterredir
How to filter for redirects. If set to nonredirects when blredirect is enabled, this is only applied to the second level.
- One of the following values: all, nonredirects, redirects
- Default: all
- bllimit
How many total pages to return. If blredirect is enabled, the limit applies to each level separately (which means up to 2 * bllimit results may be returned).
- Type: integer or max
- The value must be between 1 and 500.
- Default: 10
- blredirect
If linking page is a redirect, find all pages that link to that redirect as well. Maximum limit is halved.
- Type: boolean (details)
- Show links to MediaWiki.
- api.php?action=query&list=backlinks&bltitle=MediaWiki [open in sandbox]
- Get information about pages linking to MediaWiki.
- api.php?action=query&generator=backlinks&gbltitle=MediaWiki&prop=info [open in sandbox]
مثال
طلب GET
النتيجة
{
"batchcomplete": "",
"continue": {
"blcontinue": "1|987",
"continue": "-||"
},
"query": {
"backlinks": [
{
"pageid": 12,
"ns": 0,
"title": "Anarchism"
},
{
"pageid": 128,
"ns": 1,
"title": "Talk:Atlas Shrugged"
},
{
"pageid": 336,
"ns": 0,
"title": "Altruism"
},
...
]
}
}
عينة من الكود البرمجي
Python
#!/usr/bin/python3
"""
get_backlinks.py
MediaWiki API Demos
Demo of `Backlinks` module: Get request to list pages which link to a certain page.
MIT License
"""
import requests
S = requests.Session()
URL = "https://en.wikipedia.org/w/api.php"
PARAMS = {
"action": "query",
"format": "json",
"list": "backlinks",
"bltitle": "philosophy"
}
R = S.get(url=URL, params=PARAMS)
DATA = R.json()
BACKLINKS = DATA["query"]["backlinks"]
for b in BACKLINKS:
print(b["title"])
PHP
<?php
/*
get_backlinks.php
MediaWiki API Demos
Demo of `Backlinks` module: Get request to list pages which link to a certain page.
MIT License
*/
$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
"action" => "query",
"format" => "json",
"list" => "backlinks",
"bltitle" => "philosophy"
];
$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"]["backlinks"] as $k => $v ) {
echo( $v["title"] . "\n" );
}
JavaScript
/*
get_backlinks.js
MediaWiki API Demos
Demo of `Backlinks` module: Get request to list pages which link to a certain page.
MIT License
*/
var url = "https://en.wikipedia.org/w/api.php";
var params = {
action: "query",
format: "json",
list: "backlinks",
bltitle: "philosophy"
};
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 backlinks = response.query.backlinks;
for (var b in backlinks) {
console.log(backlinks[b].title);
}
})
.catch(function(error){console.log(error);});
MediaWiki JS
/*
get_backlinks.js
MediaWiki API Demos
Demo of `Backlinks` module: Get request to list pages which link to a certain page.
MIT License
*/
var params = {
action: 'query',
format: 'json',
list: 'backlinks',
bltitle: 'philosophy'
},
api = new mw.Api();
api.get( params ).done( function ( data ) {
var backlinks = data.query.backlinks,
b;
for ( b in backlinks ) {
console.log( backlinks[ b ].title );
}
} );
حالات إعادة التوجيه
في المثال سالف الذكر، تظهر فقط الوصلات الشبكية المباشرة إلى صفحة الفلسفة لا غير.
حينما تضبط قيمة blredirect
، سوف يتضمن الرد أي صفحات تصل عكسيًا إلى حالات إعادة توجيه للقيمة المحددة في bltitle
.
تعامل الوصلات العكسية التي يعاد توجيهها هذه في صفة مجموعات مستقلة داخل ترتيب الرد وتكون في مستوى واحد تحت حالة إعادة التوجيه ذاتها.
ينطبق الحد الأقصى المحدد في bllimit
على كل مستوى من مستويات الرد، لذا يكون رد bllimit=25
عدد يصل إلى 25 وصلة شبكية عكسية مباشرة، وعدد يصل إلى 25 وصلة شبكية عكسية داخل نطاق كل إعادة توجيه على حدة.
علاوة على ما سلف، سوف ينتج عن استخدام blcontinue
حينما توجد إعادة توجيه في الرد المزيد من الوصلات الشبكية العكسية في المستوى الثاني، قبل الانتقال في النهاية إلى وصلات شبكية عكسية مباشرة أخرى، حال رد كافة الوصلات الشبكية العكسية لحالة إعادة توجيه واحدة كاملة.
الأخطاء المحتملة
رمز | معلومات |
---|---|
blbadcontinue | متابعة غير صحيحة; يجب عليك تمرير القيمة الأصلية التي تم إرجاعها بواسطة الاستعلام السابق. |
انظر أيضا
- API:Linkshere - يبحث عن كافة الصفحات التي تصل شبكيًا إلى صفحة محددة. لاحظ أنه، وخلافا للوحدة API:Backlinks، التي هي وحدة
list
برمجية، الوحدة API:Linkshere هي وحدةprop
برمجية. طالع الصفحات المعنية التي تتناول API:Properties و واجهة برمجة التطبيقات:قوائم لترى مدى اختلاف هاتين الوحدتين البرمجيتين. - واجهة برمجة التطبيقات:مدمج_في - وحدة
prop
برمجية تبحث عن كافة الصفحات التي تضمّن (أي تدمج معلومات من) الصفحة المحددة. - واجهة برمجة التطبيقات:Embeddedin - وحدة
list
برمجية تسرد الوصلات الشبكية العكسية الناتجة عن التضمين، تشبه Special:Whatlinkshere. - واجهة برمجة التطبيقات:Imageusage - يسرد الصفحات التي تستخدم الصورة المحددة أو الصور المعينة.
- واجهة برمجة التطبيقات:Fileusage - يسرد الصفحات التي تستخدم الملف المحدد أو الملفات المعينة.
- API:Globalusage - يسرد الصفحات الموجودة على مواقع ويكي أخرى تستخدم الملف أو الملفات المعطاة، يشبه Special:GlobalUsage.