Remove HTTPoison dependency
This commit is contained in:
parent
96b2621ff5
commit
71fa17caaf
|
@ -74,37 +74,6 @@ defmodule Readability do
|
|||
@type options :: list
|
||||
@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 """
|
||||
Extract MIME Type from headers
|
||||
|
||||
|
|
Loading…
Reference in New Issue