DotNetWikiBot Framework Documentation
The Page type exposes the following members.
Constructors
Name | Description | |
---|---|---|
Page()()()() | This constructor creates Page object without title using most recently
created Site object. | |
Page(Int64) | This constructor creates Page object with specified page's numeric revision ID
(also called "oldid") using most recently created Site object. | |
Page(String) | This constructor creates Page object with specified title using most recently
created Site object. | |
Page(Site) | This constructor creates empty Page object with specified Site object,
but without title. Avoid using this constructor needlessly. | |
Page(Site, Int64) | This constructor creates Page object with specified page's numeric revision ID
(also called "oldid"). Page title is retrieved automatically
in this constructor. | |
Page(Site, String) | This constructor creates Page object with specified title and specified
Site object. This is preferable constructor. Basic title normalization occurs during
construction.
When constructed, new Page object doesn't contain text, use Load()()()()
method to get text and metadata from live wiki. |
Methods
Name | Description | |
---|---|---|
AddTemplate | Adds a specified template to the end of the page text,
but before categories. | |
AddToCategory | Adds the page to the specified category by adding a
link to that category to the very end of page's text.
If the link to the specified category
already exists, the function silently does nothing. | |
ConvertHtmlMarkupToWikiMarkup | Function converts basic HTML markup in this page's text to wiki
markup, except for tables markup. Use
ConvertHtmlTablesToWikiTables()()()() function to convert HTML
tables markup to wiki format. | |
ConvertHtmlTablesToWikiTables | Function converts HTML table markup in this page's text to wiki
table markup. | |
CorrectNsPrefix | Changes default English namespace prefixes to correct local prefixes
(e.g. for German wiki sites it changes "Category:..." to "Kategorie:..."). | |
Delete | Deletes the page. Administrator's rights are required
for this action. | |
DownloadImage | Downloads image, audio or video file, pointed by this page's title,
from the wiki site to local computer. Redirection is resolved automatically. | |
Exists | Returns true, if text field is not empty. Don't forget
to call Load()()()() before using this function. | |
FormatTemplate(String, Dictionary<(Of <<'(String, String>)>>)) | Formats a template with the specified title and parameters. Default formatting
options are used. | |
FormatTemplate(String, Dictionary<(Of <<'(String, String>)>>), String) | Formats a template with the specified title and parameters. Formatting
options are got from provided reference template. That function is usually used to
format modified template as it was in it's initial state, though absolute format
consistency can not be guaranteed. | |
FormatTemplate(String, Dictionary<(Of <<'(String, String>)>>), Boolean, Boolean, Int32) | Formats a template with the specified title and parameters, allows extended
format options to be specified. | |
GetAllCategories | Returns list of strings, containing category names found in
page's text and added by page's templates. | |
GetAllLinks | Returns the list of strings, containing all wikilinks ([[...]])
found in page's text, excluding links in image descriptions, but including
interlanguage links, links to sister wiki projects, categories, images, etc. | |
GetCategories()()()() | Returns the list of strings which contains category names found in
page's text, with namespace prefix, without sorting keys. You can use the resultant
strings to call FillFromCategory(String)
or FillFromCategoryTree(String)
function. Categories added by templates are not returned. Use GetAllCategories()
function to get such categories too. | |
GetCategories(Boolean, Boolean) | Returns the list of strings which contains categories' names found in
page text. Categories added by templates are not returned. Use
GetAllCategories()()()()
function to get categories added by templates too. | |
GetExternalLinks | Returns the list of strings which contains external links
found in page's text. | |
GetFirstTemplateParameter | This helper method returns specified parameter of a first found instance of
specified template. If no such template or no such parameter was found,
empty string "" is returned. | |
GetImages | Returns a list of files, embedded in this page. | |
GetInterLanguageLinks | Gets interlanguage links for pages on WikiMedia Foundation's
projects. | |
GetLinks | Finds all wikilinks in page text, excluding interwiki
links, categories, embedded images and links in image descriptions. | |
GetNamespace | Identifies the namespace of the page. | |
GetSecurityTokens | Gets security tokens which are required by MediaWiki to perform page
modifications. | |
GetSisterwikiLinks | Returns links to sister wiki projects, found in this page's text. These may
include interlanguage links but only those embedded in text, not those located
on wikidata.org | |
GetTemplateParameter | Returns specified parameter of a specified template. If several instances
of specified template are found in text of this page, all parameter values
are returned. | |
GetTemplates | Returns the templates found in text of this page (those inside double
curly brackets {{...}} ). MediaWiki's
"magic words"
are not returned as templates. | |
GetTitle | Retrieves the title for this Page object using page's numeric revision ID
(also called "oldid"), stored in "revision" object's property. Make sure that
"revision" property is set before calling this function. Use this function
when working with old revisions to detect if the page was renamed at some
point. | |
GetWikidataItem | For pages that have associated items on
Wikidata.org this function returns
XElement object with all information provided by Wikidata.
If page is not associated with a Wikidata item null is returned. | |
GetWikidataLinks | For pages of Wikimedia foundation projects this function returns
interlanguage links located on
Wikidata.org. | |
IsDisambig | Returns true, if this page is a disambiguation page. This function
automatically recognizes disambiguation templates on Wikipedia sites in
different languages. But in order to be used on other sites, disambig
variable must be manually set before this function is called.
disambig should contain local disambiguation template's title or
several titles delimited by '|' character, letters case doesn't matter, e.g.
"disambiguation|disambig|disam". Page text
will be loaded from wiki if it was not loaded prior to function call. | |
IsEmpty | Returns true, if text field is empty. Don't forget
to call Load()()()() before using this function. | |
IsRedirect | Returns true, if page redirects to another page. Don't forget to load
actual page contents from live wiki Load()()()() before using this
function. | |
Load | Loads page text and metadata (last revision's ID, timestamp, comment, author,
minor edit mark) from wiki site. If the page doesn't exist
it's text will be empty (""), no exception is thrown. | |
LoadFromFile | Loads page text from the specified UTF8-encoded file. | |
LoadTextOnly | Loads page text from live wiki site via raw web interface.
If Page.revision is specified, the function gets that specified
revision. If the page doesn't exist it's text will be empty (""), no exception
is thrown. This function is very fast, but it should be used only when
metadata is not needed and no page modification is required.
In other cases Load()()()() function should be used. | |
ParseTemplate | Parses the provided template body and returns the key/value pairs of it's
parameters titles and values. Everything inside the double braces must be passed to
this function, so first goes the template's title, then '|' character, and then go the
parameters. Please, see the usage example. | |
Protect | Protects or unprotects the page, so only authorized group of users can edit or
rename it. Changing page protection mode requires administrator (sysop)
rights. | |
RedirectsTo | Returns redirection target. Don't forget to load
actual page contents from live wiki Load()()()() before using this
function. | |
RemoveFromCategory | Removes the page from category by deleting link to that category in
page text. | |
RemoveTemplate | Removes all instances of a specified template from page text. | |
RemoveTemplateParameter | Removes the specified parameter of the specified template.
If several instances of specified template are found in text of this page, either
first instance can be affected or all instances. | |
RenameTo(String, String) | Renames the page. Redirection from old title to new title is
automatically created. | |
RenameTo(String, String, Boolean, Boolean) | Renames the page. Redirection from old title to new title is
automatically created. | |
ResolveRedirect | If this page is a redirection, this function loads the title and text
of redirection target page into this Page object. | |
Revert | Undoes the last edit, so page text reverts to previous contents.
The function doesn't affect other actions like renaming. | |
ReviseInMsWord | This function opens page text in Microsoft Word for editing.
Just close Word after editing, and the revised text will appear back in
text variable. | |
Save()()()() | Saves contents of text to live wiki site. Uses
defaultEditComment and minorEditByDefault
(true by default). | |
Save(String) | Saves specified text in page on live wiki. Uses
defaultEditComment and minorEditByDefault
(true by default). | |
Save(String, Boolean) | Saves text contents to live wiki site. | |
Save(String, String, Boolean) | Saves specified text on page on live wiki. | |
Save(String, String, Boolean, Boolean) | Saves specified text on page on live wiki. | |
SaveToFile()()()() | Saves text to the ".txt" file in current directory.
Use Directory.SetCurrentDirectory() function to change the current directory (but don't
forget to change it back after saving file). The name of the file is constructed
from the title of the article. Forbidden characters in filenames are replaced
with their Unicode numeric codes (also known as numeric character references
or NCRs). | |
SaveToFile(String) | Saves page text to the specified file. If the target file already exists
it is overwritten. | |
SetTemplateParameter | Sets the specified parameter of the specified template to new value.
If several instances of specified template are found in text of this page, either
first value can be set, or all values in all instances. | |
ShowText | Sends page text to console. | |
ShowTitle | Sends page title to console. | |
UndoLastEdits | Undoes all last edits made by last contributor.
The function doesn't affect other operations
like renaming or protecting. | |
Unwatch | Removes page from bot account's watchlist. | |
UploadImage | Uploads local image to wiki site. Function also works with non-image files.
Note: uploaded image title (wiki page title) will be the same as title of this Page
object, not the title of source file. | |
UploadImageFromWeb | Uploads web image to wiki site. | |
Watch | Adds this page to bot account's watchlist. |
Fields
Name | Description | |
---|---|---|
comment | Last edit comment. | |
lastBytesModified | Number of bytes modified during last edit. | |
lastLoadTime | Time of last page load (UTC). Used to detect edit conflicts. | |
lastMinorEdit | True, if last edit was minor edit. | |
lastUser | Username or IP-address of last page contributor. | |
lastUserId | Last contributor's ID in MediaWiki database. | |
pageId | Page's ID in MediaWiki database. | |
revision | Page revision ID in the MediaWiki database. | |
site | Site, on which this page is located. | |
text | Page's text. | |
timestamp | Date and time of last edit expressed in UTC (Coordinated Universal Time).
Call "timestamp.ToLocalTime()" to convert to local time if it is necessary. | |
title | Page's title, including namespace prefix. | |
watched | True, if this page is in bot account's watchlist. |