Fix whatever.scalzi.com extractor
This commit is contained in:
parent
5f3be52132
commit
bd42073e24
|
@ -18,11 +18,17 @@ defmodule Frenzy.Pipeline.Extractor.WhateverScalzi do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp get_article_content(html_tree) do
|
defp get_article_content(html_tree) do
|
||||||
case Floki.find(html_tree, "article.post > div.entry-content") do
|
# there's no element that contains only the post content
|
||||||
[content_elem | _] ->
|
# .postarea contains the headline, post content, social media buttons, and comments
|
||||||
# remove social media buttons that are included in the .entry-content element
|
with [{_tag, _attrs, postarea_children} | _] <- Floki.find(html_tree, ".postarea"),
|
||||||
Floki.filter_out(content_elem, "div#jp-post-flair")
|
{_before_headline, [_headline | rest]} <-
|
||||||
|
Enum.split_while(postarea_children, fn {tag, _attrs, _children} -> tag != "h1" end),
|
||||||
|
{article_content, _rest} <-
|
||||||
|
Enum.split_while(rest, fn {tag, attrs, _children} ->
|
||||||
|
tag != "div" || !({"id", "jp-post-flair"} in attrs)
|
||||||
|
end) do
|
||||||
|
article_content
|
||||||
|
else
|
||||||
_ ->
|
_ ->
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue