API:Iwlinks/pl

From MediaWiki.org
Jump to navigation Jump to search
This page is a translated version of the page API:Iwlinks and the translation is 57% complete.

Other languages:
English • ‎polski • ‎русский • ‎中文 • ‎日本語
Wersja MediaWiki: 1.17

GET request to list interwiki links from a given page.

Dokumentacja API


(main | query | iwlinks)

Returns all interwiki links from the given pages.

Parameters:
iwprop

Which additional properties to get for each interlanguage link:

url
Adds the full URL.
Values (separate with | or alternative): url
iwprefix

Only return interwiki links with this prefix.

iwtitle

Interwiki link to search for. Must be used with iwprefix.

iwdir

The direction in which to list.

One of the following values: ascending, descending
Default: ascending
iwlimit

How many interwiki links to return.

No more than 500 (5,000 for bots) allowed.
Type: integer or max
Default: 10
iwcontinue

When more results are available, use this to continue.

iwurl
Deprecated.

Whether to get the full URL (cannot be used with iwprop).

Type: boolean (details)
Example:
Get interwiki links from the page Main Page.
api.php?action=query&prop=iwlinks&titles=Main%20Page [open in sandbox]

Przykład

Żądanie GET

Get a list of interwiki links from Albert Einstein.

Odpowiedź

{
    "query": {
        "pages": [
            {
                "pageid": 736,
                "ns": 0,
                "title": "Albert Einstein",
                "iwlinks": [
                    {
                        "prefix": "b",
                        "title": "Introduction_to_Astrophysics/Albert_Einstein"
                    },
                    {
                        "prefix": "c",
                        "title": "Special:Search/Albert_Einstein"
                    },
                    {
                        "prefix": "commons",
                        "title": "Special:Search/Albert_Einstein"
                    },
                    ...                   
                ]
            }
        ]
    }
}

Przykładowy kod

get_iwlinks.py

#!/usr/bin/python3

"""
    get_iwlinks.py

    MediaWiki API Demos
    Demo of `Iwlinks` module: Get the interwiki links from a given page.

    MIT License
"""

import requests

S = requests.Session()

URL = "https://en.wikipedia.org/w/api.php"

PARAMS = {
    "action": "query",
    "format": "json",
    "prop": "iwlinks",
    "titles": "Albert Einstein"
}

R = S.get(url=URL, params=PARAMS)
DATA = R.json()

print(DATA)

Możliwe błędy

Kod Info
invalidparammix The title parameter may only be used with prefix.

Parameter history

  • v1.24:
    • Wprowadzono iwprop, url
    • Deprecated iwurl
  • v1.19: Wprowadzono iwdir
  • v1.18: Wprowadzono iwprefix, iwtitle

Zobacz też