Remove HTTPoison dependency
This commit is contained in:
parent
96b2621ff5
commit
71fa17caaf
|
@ -74,37 +74,6 @@ defmodule Readability do
|
||||||
@type options :: list
|
@type options :: list
|
||||||
@type headers :: list[tuple]
|
@type headers :: list[tuple]
|
||||||
|
|
||||||
@doc """
|
|
||||||
summarize the primary readable content of a webpage.
|
|
||||||
"""
|
|
||||||
@spec summarize(url, options) :: Summary.t()
|
|
||||||
def summarize(url, opts \\ []) do
|
|
||||||
opts = Keyword.merge(opts, page_url: url)
|
|
||||||
httpoison_options = Application.get_env(:readability, :httpoison_options, [])
|
|
||||||
%{status_code: _, body: raw, headers: headers} = HTTPoison.get!(url, [], httpoison_options)
|
|
||||||
|
|
||||||
case is_response_markup(headers) do
|
|
||||||
true ->
|
|
||||||
html_tree =
|
|
||||||
raw
|
|
||||||
|> Helper.normalize(url: url)
|
|
||||||
|
|
||||||
article_tree =
|
|
||||||
html_tree
|
|
||||||
|> ArticleBuilder.build(opts)
|
|
||||||
|
|
||||||
%Summary{
|
|
||||||
title: title(html_tree),
|
|
||||||
authors: authors(html_tree),
|
|
||||||
article_html: readable_html(article_tree),
|
|
||||||
article_text: readable_text(article_tree)
|
|
||||||
}
|
|
||||||
|
|
||||||
_ ->
|
|
||||||
%Summary{title: nil, authors: nil, article_html: nil, article_text: raw}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Extract MIME Type from headers
|
Extract MIME Type from headers
|
||||||
|
|
||||||
|
|
1
mix.exs
1
mix.exs
|
@ -41,7 +41,6 @@ defmodule Readability.Mixfile do
|
||||||
defp deps do
|
defp deps do
|
||||||
[
|
[
|
||||||
{:floki, "~> 0.20"},
|
{:floki, "~> 0.20"},
|
||||||
{:httpoison, "~> 0.13.0"},
|
|
||||||
{:ex_doc, "~> 0.14", only: :dev},
|
{:ex_doc, "~> 0.14", only: :dev},
|
||||||
{:credo, "~> 0.9", only: [:dev, :test]},
|
{:credo, "~> 0.9", only: [:dev, :test]},
|
||||||
{:dialyxir, "~> 0.3", only: [:dev]},
|
{:dialyxir, "~> 0.3", only: [:dev]},
|
||||||
|
|
Loading…
Reference in New Issue