FandomPage class

class fandom.FandomPage(wiki, language, title=None, pageid=None, redirect=True, preload=False)

Contains data from a fandom page. Uses property methods to filter data from the raw HTML.

Warning

Do not manually init fandom.FandomPage. Instead call fandom.page().

Variables
  • title – The title of the page

  • pageid – The page id of the page

  • language – The language of the page

  • wiki – The wiki the page is on

  • url – The url to the page

property content

Text content of each section of the page, excluding images, tables, and other data. The content is returned as dict, imitating the section and subsection structure of the page.

Note

If you just want the plain text of the page without the section structure, you can use FandomPage.plain_text

Returns

dict

property html

Get full page HTML.

Returns

str

property images

List of URLs of images on the page.

Returns

list

property plain_text

The plain text contents of a page.

Note

If you want the section and subsection structure of the page as well as the text, you can use FandomPage.content.

Returns

str

property revision_id

Revision ID of the page.

Note

The revision ID is a number that uniquely identifies the current version of the page. It can be used to create the permalink or for other direct API calls.

Returns

int

section(section_title: str)

Get the plain text content of a section from self.sections. Returns None if section_title isn’t found, otherwise returns a str.

Warning

When calling this function, subheadings in the section you asked for are part of the plain text. If you want more control of what data you get, you should use FandomPage.content

Parameters

section_title (str) – The title of the section you want the text from.

Returns

str

property sections

List of section titles.

Returns

list

property summary

Plain text summary of the page. The summary is usually the first section up until the first newline.

Returns

str