API:Backlinks/da: Difference between revisions
Saederup92 (talk | contribs) Created page with "== API-dokumentation ==" |
Saederup92 (talk | contribs) Created page with "=== Omdirigeringer ===" |
||
| Line 89: | Line 89: | ||
</div> |
</div> |
||
=== |
=== Omdirigeringer === |
||
In the example above, only direct links to the philosophy page are returned. |
In the example above, only direct links to the philosophy page are returned. |
||
Revision as of 13:53, 8 January 2019
| This page is part of the MediaWiki Action API documentation. |
| MediaWiki-version: | ≥ 1.9 |
Get request to list pages which link to a certain page.
API-dokumentation
list=backlinks (bl)
Find all pages that link to the given page. Specific parameters: Other general parameters are available.
Examples:
|
Eksempel
GET Request
Response
{
"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"
},
...
]
}
}
Sample code
get_backlinks.py
#!/usr/bin/python3
"""
get_backlinks.py
MediaWiki Action API Code Samples
Demo of `API: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()
print(DATA)
Omdirigeringer
In the example above, only direct links to the philosophy page are returned.
When blredirect is set, the response will include any pages which backlink to redirects for the value in bltitle.
These redirected backlinks are treated as separate groups within the response hierarchy, one level down from the redirect itself.
The limit set in bllimit applies separately to each level of the response, so bllimit=25 would return up to 25 direct backlinks, and up to 25 backlinks within each individual redirect.
In addition, using blcontinue when a redirect was in the response will return more second-level backlinks, before finally moving on to more direct backlinks, once all the backlinks for a redirect have been returned in full.
Mulige fejl
| Kode | Information |
|---|---|
| blbadcontinue | Invalid continue param. You should pass the original value returned by the previous query. |
Se også
- API:Linkshere - finds all pages that link to a given page. Note that, unlike API:Backlinks, which is a
listmodule, API:Linkshere is apropmodule. See the respective pages on API:Properties and API:Lists for how these two kinds of modules differ. - API:Transcludedin - a
propmodule that finds all pages that transclude (i.e. embed information from) the given pages. - API:Embeddedin - a
listmodule which lists backlinks via transclusion, similar to Special:Whatlinkshere. - API:Imageusage - lists pages that use the given image(s).
- API:Fileusage - lists pages that use the given file(s).