Jump to content

API: ব্যাকলিঙ্ক

From mediawiki.org
This page is a translated version of the page API:Backlinks and the translation is 92% complete.
মিডিয়াউইকি সংস্করণ:
1.9

GET request to list pages which link to a certain page.

API নথি

(main | query | backlinks)
  • 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.

Specific parameters:
Other general parameters are available.
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, 1728, 1729, 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)

উদাহরণ

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 Invalid continue param. You should pass the original value returned by the previous query.

আরও দেখুন

  • API:Linkshere – একটি প্রদত্ত পৃষ্ঠার সাথে সংযুক্ত সমস্ত পৃষ্ঠাগুলি খুঁজে পায়। মনে রাখবেন যে, API:Backlinks-এর বিপরীতে, যা একটি list মডিউল, API:Linkshere হল একটি prop মডিউল। এই দুই ধরনের মডিউলের মধ্যে পার্থক্যের জন্য API:Properties এবং API:Lists -এর সংশ্লিষ্ট পৃষ্ঠাগুলি দেখুন।
  • API:Transcludedin a prop module that finds all pages that transclude (i.e. embed information from) the given pages.
  • API:Embeddedin – একটি list মডিউল যা ট্রান্সক্লুশনের মাধ্যমে ব্যাকলিঙ্কগুলি তালিকাভুক্ত করে, Special:Whatlinkshere এর অনুরূপ।
  • API:Imageusage – প্রদত্ত চিত্র ব্যবহার করে এমন পৃষ্ঠাগুলির তালিকা করে।
  • API:Fileusage – যে-পৃষ্ঠাগুলি প্রদত্ত ফাইল ব্যবহার করে, সেগুলিকে তালিকাভুক্ত করে।
  • API:Globalusage – অন্যান্য উইকির পৃষ্ঠাগুলি তালিকাভুক্ত করে যা প্রদত্ত ফাইলটি ব্যবহার করে (Special:GlobalUsage এর অনুরূপ) ।