Manual:Parameters to Special:Export

From MediaWiki.org

(Redirected from Parameters to Special:Export)
Jump to: navigation, search

Wiki pages can be exported in a special XML format to upload import into another MediaWiki installation (if this function is enabled on the destination wiki, and the user is a sysop there) or use it elsewise for instance for analysing the content. See also Syndication feeds for exporting other information but pages and Help:Import on importing pages. See Help:Export for more details.

Contents

[edit] Available parameters

Below is the available parameters for Special:Export.[1][2]

pages

A list of page titles, separated by linefeed (%0A) characters.

action

Unused; set to "submit" in the export form

dir

Should be set to "desc" to retrieve revisions in reverse chronological order.

The default, with this parameter omitted, is to retrieve revisions in ascending order of timestamp (newest to oldest).

offset

The timestamp at which to start, which is non-inclusive. The timestamp may be in several formats, including the 14-character format usually used by MediaWiki, and an ISO 8601 format like the one output in the XML dumps.

limit

The maximum number of revisions to return. If you request more than a site-specific maximum (100 on Wikipedia at present), it will be reduced to this number.

This limit is cumulative across all the pages specified in the pages parameter. For example, if you request a limit of 100, for two pages with 70 revisions each, you will get 70 from one and 30 from the other.[3]

[edit] URL parameter requests do not work

The dir, offset and limit parameter only work for POST requests. GET requests through a URL are ignored.

When you use the URL as in a browser, you are submitting via GET. In the ruby script, you are using POST.

As an example, the following parameter request does not work, it returns all revisions of a page despite the parameter limit=5.

http://en.wikipedia.org/w/index.php?title=Special:Export&pages=XXXX&offset=1&limit=5&action=submit&history

[edit] Retrieving earliest 5 revisions

Note: User:Stefan.petrea writes: All the curl and Python and ruby examples are broken. They retrieve the whole history instead of what they're supposed to. Please fix them , thank you.


A POST request is generated by cURL when passing -d "". The following retrieves the earliest 5 revisions from the English Wikipedia main page:

curl -d "" 'http://en.wikipedia.org/w/index.php?title=Special:Export&pages=Main_Page&offset=1&limit=5&action=submit'

And here is the next 5 revisions:

curl -d "" 'http://en.wikipedia.org/w/index.php?title=Special:Export&pages=Main_Page&offset=2002-01-27T20:25:56Z&limit=5&action=submit'

Here the timestamp from the last revision of the previous query is copied into the offset field of the URL. Because the offset field is non-inclusive, that 5th revision is not displayed again, instead we get revisions 6-10.[4]

[edit] addcat and catname

The parameters addcat and catname were added later. addcat returns all members of the category catname added to it.

For example, the following is for all pages in en:Category:Books:

http://en.wikipedia.org/w/index.php?title=Special:Export&addcat&catname=Books&pages=XXXX

[edit] Stopping the export of your mediawiki

If $wgExportAllowHistory is set to false in LocalSettings.php, only the current version can be exported, not the full history.

By default, only the current (last) version of each page is returned.

If the $wgExportAllowHistory parameter is true in LocalSettings.php, and the "Include only the current revision, not the full history" is unchecked, then all versions of each page are returned.

[edit] Notes

  1. For use with custom clients such as IBM History Flow.
  2. In August 2006, Tim Starling implemented an experimental interface for history paging in Special:Export. He added three new parameters, currently with no user interface.
  3. The order is by page_id, pages with lower page_id get more revisions. The reason for this is that Special:Export only ever does one database query per HTTP request. If you want to request all the history of several pages with many revisions each, you have to do it one page at a time.
  4. This parameter convention is very similar to the one for UI history pages.

[edit] External links