Last active
February 5, 2020 06:54
-
-
Save iantbutler01/dc9e25e650603e7445af958ce89b2446 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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