fandom package¶
Submodules¶
Module functions¶
-
fandom.
search
(query: str, wiki: str = '', language: str = '', results: int = 10)¶ Do a fandom search.
The search returns a list of tuples, with the page title and the page id.
-
fandom.
summary
(title: str, wiki: str = '', language: str = '', sentences: int = - 1, redirect: bool = True)¶ Plain text summary of the page with the requested title. Is just an implementation of
FandomPage.summary
, but with the added functionality of requesting a specific amount of sentences.- Parameters
title (str) – The title of the page to get the summary of
wiki (str) – The wiki to search (defaults to the global wiki variable. If the global wiki variable is not set, defaults to “runescape”)
language (str) – The language to search in (defaults to the global language variable. If the global language variable is not set, defaults to english)
sentences (int) – The maximum number of sentences to output. Defaults to the whole summary
redirect (bool) – Allow redirection without raising RedirectError
-
fandom.
page
(title: str = '', pageid: int = - 1, wiki: str = '', language: str = '', redirect: bool = True, preload: bool = False)¶ Get a FandomPage object for the page in the sub fandom with title or the pageid (mutually exclusive).
- Parameters
title (str) –
the title of the page to load
pageid (int) – The numeric pageid of the page to load
wiki (str) – The wiki to search (defaults to the global wiki variable. If the global wiki variable is not set, defaults to “runescape”)
language (str) – The language to search in (defaults to the global language variable. If the global language variable is not set, defaults to english)
redirect (bool) – Allow redirection without raising RedirectError
preload (bool) – Load content, summary, images, references, and links during initialization
-
fandom.
random
(pages: int = 1, wiki: str = '', language: str = '')¶ Get a list of random fandom article titles.
Returns the results as tuples with the title and page id.
Note
Random only gets articles from namespace 0, meaning only articles
- Parameters
pages (int) – the number of random pages returned (max of 10)
wiki (str) – The wiki to search (defaults to the global wiki variable. If the global wiki variable is not set, defaults to “runescape”)
language (str) – The language to search in (defaults to the global language variable. If the global language variable is not set, defaults to english)
- Returns
tuple
if the pages parameter was 1,list
oftuple
if it was larger
-
fandom.
set_lang
(language: str)¶ Sets the global language variable
- Parameters
language (str) – The language to set as the global language variable
-
fandom.
set_rate_limiting
(rate_limit: bool, min_wait: int = 50)¶ Enable or disable rate limiting on requests to the fandom servers. If rate limiting is not enabled, under some circumstances (depending on load on fandom, the number of requests you and other fandom users are making, and other factors), fandom may return an HTTP timeout error.
Note
Enabling rate limiting generally prevents that issue, but please note that HTTPTimeoutError still might be raised.