ExWikipedia.Page (ex_wikipedia v0.4.0)

ExWikipedia.page/2 delegates here. This module represents the current implementation for requesting and parsing a Wikipedia page.

Link to this section Summary

Types

t()
  • :external_links - List of fully qualified URLs linked from the Wikipedia page.
  • :categories - List of categories to which the Wikipedia page belongs
  • :content - Main content of the Wikipedia page, as a string
  • :images - List of relative URLs pointing to images found on the Wikipedia page
  • :page_id - Wikipedia page id represented as an integer
  • :revision_id - Wikipedia page revision id represented as an integer
  • :summary - Summary of page, as a string
  • :title - String title of the Wikipedia page
  • :url - Fully qualified URL of the Wikipedia page
  • :is_redirect? - Boolean. Indicates whether the content is from a page redirected from the one requested.

Functions

Fetches a Wikipedia page by an identifier (see :by option).

Constructs a fully qualified Wikipedia URL using supplied args. The id_key specifies what field will be used to query the id_value e.g. [:page, :pageid]. The id_value is the actual query we are trying to look up via the Wikipedia API. lang specifies the language of the Wikipedia endpoint we will be searching.

Link to this section Types

@type t() :: %ExWikipedia.Page{
  categories: [String.t()],
  content: String.t(),
  external_links: [String.t()],
  images: [String.t()],
  is_redirect?: boolean(),
  links: [String.t()],
  page_id: non_neg_integer(),
  revision_id: non_neg_integer(),
  summary: String.t(),
  title: String.t(),
  url: String.t()
}
  • :external_links - List of fully qualified URLs linked from the Wikipedia page.
  • :categories - List of categories to which the Wikipedia page belongs
  • :content - Main content of the Wikipedia page, as a string
  • :images - List of relative URLs pointing to images found on the Wikipedia page
  • :page_id - Wikipedia page id represented as an integer
  • :revision_id - Wikipedia page revision id represented as an integer
  • :summary - Summary of page, as a string
  • :title - String title of the Wikipedia page
  • :url - Fully qualified URL of the Wikipedia page
  • :is_redirect? - Boolean. Indicates whether the content is from a page redirected from the one requested.

Link to this section Functions

Link to this function

fetch(id, opts \\ [])

Fetches a Wikipedia page by an identifier (see :by option).

options

Options

  • :http_client: HTTP Client used to fetch Wikipedia page via Wikipedia's integer ID. Default: Elixir.HTTPoison
  • :decoder: Decoder used to decode JSON returned from Wikipedia API. Default: Elixir.Jason
  • :http_headers: HTTP headers that are passed into the client. Default: []
  • :http_opts: HTTP options passed to the client. Default: []
  • :body_key: key inside the HTTP client's response which contains the response body. This may change depending on the client used. Default: body
  • :status_key: key inside the HTTP client's response which returns the HTTP status code. This may change depending on the client used. Default: status_code
  • :parser: Parser used to parse response returned from client. Default: ExWikipedia.PageParser
  • :parser_opts: Parser options passed the the parser. Default: []. See ExWikipedia.PageParser for supported options.
  • :allow_redirect: indicates whether or not the content from a redirected page constitutes a valid response. Default: true
  • :language: Identifies a specific Wikipedia instance to search. You can use the :default_language config option to set this value. Default: en
  • :by: The field used to identify the page. [:page, :pageid].
Link to this function

url(id_key, id_value, lang)

(since 0.4.0)

Constructs a fully qualified Wikipedia URL using supplied args. The id_key specifies what field will be used to query the id_value e.g. [:page, :pageid]. The id_value is the actual query we are trying to look up via the Wikipedia API. lang specifies the language of the Wikipedia endpoint we will be searching.