Skip to content

Instantly share code, notes, and snippets.

@iantbutler01
Last active February 5, 2020 06:54
Show Gist options
  • Save iantbutler01/dc9e25e650603e7445af958ce89b2446 to your computer and use it in GitHub Desktop.
Save iantbutler01/dc9e25e650603e7445af958ce89b2446 to your computer and use it in GitHub Desktop.
defp get_children_urls(body) do
Floki.find(body, "div#readme")
|> Floki.find("div.Box-body")
|> Floki.find("a")
|> Floki.attribute("href")
|> Enum.filter(fn url ->
%URI{host: host, path: path} = URI.parse(url)
case host do
nil -> false
_ ->
with false <- path == nil,
true <- String.match?(host, ~r/.*github\.com$/),
true <- length(String.split(path, "/")) == 3,
false <- Enum.at(String.split(path, "/"), 1) == "sponsors" do
true
else
_ -> false
end
end
end)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment