readability2 v0.4.0 Readability

Readability library for extracting & curating articles.

Example

@type html :: binary

# Just pass url
%Readability.Summary{title: title, authors: authors, article_html: article} = Readability.summarize(url)

# Extract title
Readability.title(html)

# Extract authors.
Readability.authors(html)

# Extract only text from article
article = html
          |> Readability.article
          |> Readability.readable_text

# Extract article with transformed html
article = html
          |> Readability.article
          |> Readability.raw_html

Link to this section Summary

Functions

Using a variety of metrics (content score, classname, element types), find the content that is most likely to be the stuff a user wants to read

Extract authors

Return true if Content-Type in provided headers list is a markup type, else false

Extract MIME Type from headers

return raw html binary from html_tree

return attributes, tags cleaned html

return only text binary from html_tree

summarize the primary readable content of a webpage.

Extract title

Link to this section Types

Specs

headers() :: list()[tuple()]

Specs

html_tree() :: tuple() | list()

Specs

options() :: list()

Specs

raw_html() :: binary()

Specs

url() :: binary()

Link to this section Functions

Link to this function

article(raw_html, opts \\ [])

Specs

article(binary(), options()) :: html_tree()

Using a variety of metrics (content score, classname, element types), find the content that is most likely to be the stuff a user wants to read

Example

iex> article_tree = Redability(html_str)
# returns article that is tuple

Specs

authors(binary() | html_tree()) :: list()[binary()]

Extract authors

Example

iex> authors = Readability.authors(html_str)
["José Valim", "chrismccord"]
Link to this function

default_options()

Link to this function

is_response_markup(headers)

Specs

is_response_markup(headers()) :: boolean()

Return true if Content-Type in provided headers list is a markup type, else false

Example

iex> Readability.is_response_markup?([{"Content-Type", "text/html"}])
true
Link to this function

mime(headers \\ [])

Specs

mime(headers()) :: String.t()

Extract MIME Type from headers

Example

iex> mime = Readability.mime(headers_list)
"text/html"
Link to this function

parse(raw_html)

Link to this function

raw_html(html_tree)

Specs

raw_html(html_tree()) :: binary()

return raw html binary from html_tree

Link to this function

readable_html(html_tree)

Specs

readable_html(html_tree()) :: binary()

return attributes, tags cleaned html

Link to this function

readable_text(html_tree)

Specs

readable_text(html_tree()) :: binary()

return only text binary from html_tree

Link to this function

summarize(url, opts \\ [])

Specs

summarize(url(), options()) :: Readability.Summary.t()

summarize the primary readable content of a webpage.

Link to this function

title(raw_html)

Specs

title(binary() | html_tree()) :: binary()

Extract title

Example

iex> title = Readability.title(html_str)
"Some title in html"