28 lines
635 B
Elixir
28 lines
635 B
Elixir
defmodule Frenzy.Pipeline.Extractor.EricaSadun do
|
|
@moduledoc """
|
|
Extractor for https://ericasadun.com
|
|
"""
|
|
|
|
alias Frenzy.Pipeline.Extractor
|
|
@behaviour Extractor
|
|
|
|
@impl Extractor
|
|
def extract(body) do
|
|
html_tree = Floki.parse(body)
|
|
|
|
case Floki.find(html_tree, ".post-content") do
|
|
[content_elem | _] ->
|
|
# content element includes social media buttons and related posts
|
|
content =
|
|
content_elem
|
|
|> Floki.filter_out("div.sharedaddy, div#jp-relatedposts")
|
|
|> Floki.raw_html()
|
|
|
|
{:ok, content}
|
|
|
|
_ ->
|
|
{:error, "no matching elements"}
|
|
end
|
|
end
|
|
end
|