Compare commits
2 Commits
b443afcbf2
...
b9be2879ed
Author | SHA1 | Date |
---|---|---|
Shadowfacts | b9be2879ed | |
Shadowfacts | 852db1520f |
|
@ -0,0 +1,19 @@
|
||||||
|
defmodule Frenzy.Pipeline.Extractor.Birchtree do
|
||||||
|
@moduledoc """
|
||||||
|
Extractor for https://birchtree.me
|
||||||
|
"""
|
||||||
|
|
||||||
|
alias Frenzy.Pipeline.Extractor
|
||||||
|
@behaviour Extractor
|
||||||
|
|
||||||
|
@impl Extractor
|
||||||
|
def extract(html_tree) do
|
||||||
|
case Floki.find(html_tree, "section.post-content") do
|
||||||
|
[content_elem | _] ->
|
||||||
|
{:ok, content_elem}
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
{:error, "no matching elements"}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -158,6 +158,16 @@ defmodule Frenzy.Pipeline.ScrapeStage do
|
||||||
attr
|
attr
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
has_src = Enum.find(new_attrs, fn {name, _} -> name == "src" end)
|
||||||
|
|
||||||
|
# remove srcsets because our transformation only applies to the src attribute, so that should always be used
|
||||||
|
new_attrs =
|
||||||
|
if has_src do
|
||||||
|
Enum.reject(new_attrs, fn {name, _} -> name == "srcset" end)
|
||||||
|
else
|
||||||
|
new_attrs
|
||||||
|
end
|
||||||
|
|
||||||
{"img", new_attrs}
|
{"img", new_attrs}
|
||||||
|
|
||||||
elem ->
|
elem ->
|
||||||
|
@ -191,5 +201,5 @@ defmodule Frenzy.Pipeline.ScrapeStage do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp image_to_data_uri(src, _site_uri, false), do: src
|
defp image_to_data_uri(src, site_uri, false), do: to_string(URI.merge(site_uri, src))
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,7 @@ defmodule FrenzyWeb.ConfigureStage.ScrapeStageLive do
|
||||||
{"512 Pixels", Frenzy.Pipeline.Extractor.FiveTwelvePixels},
|
{"512 Pixels", Frenzy.Pipeline.Extractor.FiveTwelvePixels},
|
||||||
{"Ars Technica", Frenzy.Pipeline.Extractor.ArsTechnica},
|
{"Ars Technica", Frenzy.Pipeline.Extractor.ArsTechnica},
|
||||||
{"beckyhansmeyer.com", Frenzy.Pipeline.Extractor.BeckyHansmeyer},
|
{"beckyhansmeyer.com", Frenzy.Pipeline.Extractor.BeckyHansmeyer},
|
||||||
|
{"birchtree.me", Frenzy.Pipeline.Extractor.Birchtree},
|
||||||
{"daringfireball.net", Frenzy.Pipeline.Extractor.DaringFireball},
|
{"daringfireball.net", Frenzy.Pipeline.Extractor.DaringFireball},
|
||||||
{"ericasadun.com", Frenzy.Pipeline.Extractor.EricaSadun},
|
{"ericasadun.com", Frenzy.Pipeline.Extractor.EricaSadun},
|
||||||
{"finertech.com", Frenzy.Pipeline.Extractor.FinerTech},
|
{"finertech.com", Frenzy.Pipeline.Extractor.FinerTech},
|
||||||
|
|
Loading…
Reference in New Issue